Google Maps: Polygon and Marker Z-Index The 2019 Stack Overflow Developer Survey Results Are InGoogle Map zIndex of PolylineGoogle Maps Polygone “clickable: false” shows no effectGoogle maps polyline click between two narrow markers is wrongHow to insert an item into an array at a specific index (JavaScript)?Google Maps API v3: How to remove all markers?How to disable mouse scroll wheel scaling with Google Maps APIWhy does Google prepend while(1); to their JSON responses?Google Maps JS API v3 - Simple Multiple Marker ExampleMax initial zIndex for Google Maps V3 markersGoogle Maps API V3 - KML Layer vs. JS created PolygonsSpecify the z-index of Google Map MarkersHow to remove circle,polygon from google map completelyAdd and Remove Marker For Polygon Shape Change on Google Map

Return to UK after having been refused entry years ago

Can we generate random numbers using irrational numbers like π and e?

Worn-tile Scrabble

What is the meaning of Triage in Cybersec world?

How to answer pointed "are you quitting" questioning when I don't want them to suspect

What is the meaning of the verb "bear" in this context?

Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?

Why isn't the circumferential light around the M87 black hole's event horizon symmetric?

Loose spokes after only a few rides

Can a flute soloist sit?

What do hard-Brexiteers want with respect to the Irish border?

Is "plugging out" electronic devices an American expression?

Why do UK politicians seemingly ignore opinion polls on Brexit?

Multiply Two Integer Polynomials

Protecting Dualbooting Windows from dangerous code (like rm -rf)

Identify boardgame from Big movie

Why isn't airport relocation done gradually?

What tool would a Roman-age civilization have for the breaking of silver and other metals into dust?

Feature engineering suggestion required

Landlord wants to switch my lease to a "Land contract" to "get back at the city"

Did Section 31 appear in Star Trek: The Next Generation?

Does the shape of a die affect the probability of a number being rolled?

Pokemon Turn Based battle (Python)

Did 3000BC Egyptians use meteoric iron weapons?



Google Maps: Polygon and Marker Z-Index



The 2019 Stack Overflow Developer Survey Results Are InGoogle Map zIndex of PolylineGoogle Maps Polygone “clickable: false” shows no effectGoogle maps polyline click between two narrow markers is wrongHow to insert an item into an array at a specific index (JavaScript)?Google Maps API v3: How to remove all markers?How to disable mouse scroll wheel scaling with Google Maps APIWhy does Google prepend while(1); to their JSON responses?Google Maps JS API v3 - Simple Multiple Marker ExampleMax initial zIndex for Google Maps V3 markersGoogle Maps API V3 - KML Layer vs. JS created PolygonsSpecify the z-index of Google Map MarkersHow to remove circle,polygon from google map completelyAdd and Remove Marker For Polygon Shape Change on Google Map



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








29















I have a Google Map with many markers (yellow circles), and I implemented a tool to draw polygons over the markers. However, the polygon is behind the markers while drawing (and stays behind when complete).



Active polygon drawing tool beneath the markers.



I tried changing the ZIndex in both markers and polygons, but it seems to alter the way in which markers are shown with respect to other markers, and not with respect to polygons. I also tried



polygon.setZIndex(google.maps.Marker.MAX_ZINDEX + 1);


How can I bring the polygon to the front?










share|improve this question
























  • You may be able to use Overlays. I have no experience with Google's API, but I could show you how to do it in Bing Maps.

    – Corey Ogburn
    Mar 28 '13 at 3:03


















29















I have a Google Map with many markers (yellow circles), and I implemented a tool to draw polygons over the markers. However, the polygon is behind the markers while drawing (and stays behind when complete).



Active polygon drawing tool beneath the markers.



I tried changing the ZIndex in both markers and polygons, but it seems to alter the way in which markers are shown with respect to other markers, and not with respect to polygons. I also tried



polygon.setZIndex(google.maps.Marker.MAX_ZINDEX + 1);


How can I bring the polygon to the front?










share|improve this question
























  • You may be able to use Overlays. I have no experience with Google's API, but I could show you how to do it in Bing Maps.

    – Corey Ogburn
    Mar 28 '13 at 3:03














29












29








29


5






I have a Google Map with many markers (yellow circles), and I implemented a tool to draw polygons over the markers. However, the polygon is behind the markers while drawing (and stays behind when complete).



Active polygon drawing tool beneath the markers.



I tried changing the ZIndex in both markers and polygons, but it seems to alter the way in which markers are shown with respect to other markers, and not with respect to polygons. I also tried



polygon.setZIndex(google.maps.Marker.MAX_ZINDEX + 1);


How can I bring the polygon to the front?










share|improve this question
















I have a Google Map with many markers (yellow circles), and I implemented a tool to draw polygons over the markers. However, the polygon is behind the markers while drawing (and stays behind when complete).



Active polygon drawing tool beneath the markers.



I tried changing the ZIndex in both markers and polygons, but it seems to alter the way in which markers are shown with respect to other markers, and not with respect to polygons. I also tried



polygon.setZIndex(google.maps.Marker.MAX_ZINDEX + 1);


How can I bring the polygon to the front?







javascript google-maps google-maps-api-3






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Oct 19 '13 at 13:00







Nicolas

















asked Mar 26 '13 at 0:32









NicolasNicolas

1,02821532




1,02821532












  • You may be able to use Overlays. I have no experience with Google's API, but I could show you how to do it in Bing Maps.

    – Corey Ogburn
    Mar 28 '13 at 3:03


















  • You may be able to use Overlays. I have no experience with Google's API, but I could show you how to do it in Bing Maps.

    – Corey Ogburn
    Mar 28 '13 at 3:03

















You may be able to use Overlays. I have no experience with Google's API, but I could show you how to do it in Bing Maps.

– Corey Ogburn
Mar 28 '13 at 3:03






You may be able to use Overlays. I have no experience with Google's API, but I could show you how to do it in Bing Maps.

– Corey Ogburn
Mar 28 '13 at 3:03













4 Answers
4






active

oldest

votes


















56





+50









This won't solve the problem, but it will explain why the things you tried didn't work.



The Maps API uses several layers known as MapPanes in a fixed Z order:



  • 4: floatPane (infowindow)

  • 3: overlayMouseTarget (mouse events)

  • 2: markerLayer (marker images)

  • 1: overlayLayer (polygons, polylines, ground overlays, tile layer overlays)

  • 0: mapPane (lowest pane above the map tiles)

So the marker images in layer 2 are always above the polygons in layer 1. When you fiddle with the z-index on the markers, you're just adjusting them relative to each other. That doesn't do any good, because they are all in a layer above the polygons.



What can you do about this? The only solution I can think of is to create your own OverlayView for the polygons or the markers so you can put them in the MapPane you want.



Are your markers clickable, or are they just static images? If they aren't clickable, you could possibly get away with drawing them yourself in the mapPane. Then your polygons would be above them. Or the opposite: you could draw the polygons yourself in one of the higher layers, maybe in floatShadow.



The problem then is you have to do all of your own drawing, either with a canvas element or with DOM images. And your own mouse hit testing too if they are clickable.



There aren't a lot of good OverlayView examples out there, but I'll mention one of my own: a little library I wrote a while ago called PolyGonzo, where the polygonzo.js file has the OverlayView implementation. The code isn't great - I threw it together in too much of a hurry - but it may help give you some ideas.






share|improve this answer

























  • Thank you for the answer. The markers are clickable, and the polygons are drawn by the users and that is why I wanted to go with the google.maps.drawing library.

    – Nicolas
    Mar 30 '13 at 13:15






  • 1





    Bummer. Yeah, the way they put polygons in the overlayLayer makes it tricky. You either have to implement your own polygons or your own markers. No easy solution here. You could implement your own markers and put them way down in the mapLayer, with matching transparent elements in the overlayMouseTarget layer for mouse hit testing.

    – Michael Geary
    Mar 30 '13 at 21:49







  • 1





    Partially transparent markers might be a possible compromise, allowing the underlying polygon to be seen under the markers. Not perfect, but simple with custom .png image(s).

    – Beetroot-Beetroot
    Nov 2 '13 at 16:39











  • @MichaelGeary Thank you very much!! Saved my time

    – blackDelta-Δ
    Jul 27 '15 at 12:34


















6














I know this question is old but for future users I wanna share my approach:



Shapes with higher zIndex values displaying in front of those with lower values. For this example I am using Polygon but is similar for other shapes:



var globalZIndex = 1; //Be sure you can access anywhere
//... Other instructions for creating map, polygon and any else
polygon.setOptions( zIndex: globalZIndex++ );


Notice that markers have a method setZIndex(zIndex:number).






share|improve this answer























  • code example makes it clear

    – Developerium
    Feb 7 '16 at 6:41











  • FIX: setZIndex(number)

    – Zhenya
    Feb 9 '16 at 21:12


















0














Hello for me A found this solution



for Create Symbol



var lineSymbol = 
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
strokeColor: '#181727',
fillColor: '#50040B',

;

var dashedSymbol =
path: 'M 0,-1 0,1',
strokeOpacity: 1,
scale: 4

;

[![function MakeMarker(pinColor)" + pinColor,
new google.maps.Size(21, 34),
new google.maps.Point(0,0),
new google.maps.Point(10, 34));

return pinImage;

][1]][1]

FlowMarkersdashed(new google.maps.LatLng(positionorigin[0], positionorigin[1]),
new google.maps.LatLng(positiondestination[0], positiondestination[1]), myObject[i]['flowfluxphysique'][j]['colorFlux'], dashedSymbol, j);

function FlowMarkersdashed(latlngOrgin, latlngDest, ColorFlow, Symbol, indexvar)

var flightPlanCoordinates = [
latlngOrgin,
lat: latlngOrgin.lat() + (indexvar) * 2, lng: latlngOrgin.lng(),
// lat: -18.142, lng: 178.431,
latlngDest,
];
var line = new google.maps.Polyline(
path: flightPlanCoordinates,
strokeOpacity: 0,
icons: [
icon: Symbol,
// offset: '100%',
offset: '0',
repeat: '20px'

// repeat: '20px'
],
strokeColor: "#"+ColorFlow,
geodesic: true,

// editable: true,

map: map
);



And For Create a Flow Marker Simple



FlowMarkers(new google.maps.LatLng(positionorigin[0], positionorigin[1]),
new google.maps.LatLng(positiondestination[0], positiondestination[1]), myObject[i]['flowfluxinformation'][j]['colorFlux'], lineSymbol,j);


function FlowMarkersdashed(latlngOrgin, latlngDest, ColorFlow, Symbol, indexvar)

var flightPlanCoordinates = [
latlngOrgin,
lat: latlngOrgin.lat() + (indexvar) * 2, lng: latlngOrgin.lng(),
// lat: -18.142, lng: 178.431,
latlngDest,
];
var line = new google.maps.Polyline(
path: flightPlanCoordinates,
strokeOpacity: 0,
icons: [
icon: Symbol,
// offset: '100%',
offset: '0',
repeat: '20px'

// repeat: '20px'
],
strokeColor: "#"+ColorFlow,
geodesic: true,

// editable: true,

map: map
);



And Finally this is my result



enter image description here






share|improve this answer






























    -1














    Change this method call:



    polygon.setZIndex(google.maps.Marker.MAX_ZINDEX + 1); 


    to this:



    polygon.setZIndex(4);





    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f15627325%2fgoogle-maps-polygon-and-marker-z-index%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      56





      +50









      This won't solve the problem, but it will explain why the things you tried didn't work.



      The Maps API uses several layers known as MapPanes in a fixed Z order:



      • 4: floatPane (infowindow)

      • 3: overlayMouseTarget (mouse events)

      • 2: markerLayer (marker images)

      • 1: overlayLayer (polygons, polylines, ground overlays, tile layer overlays)

      • 0: mapPane (lowest pane above the map tiles)

      So the marker images in layer 2 are always above the polygons in layer 1. When you fiddle with the z-index on the markers, you're just adjusting them relative to each other. That doesn't do any good, because they are all in a layer above the polygons.



      What can you do about this? The only solution I can think of is to create your own OverlayView for the polygons or the markers so you can put them in the MapPane you want.



      Are your markers clickable, or are they just static images? If they aren't clickable, you could possibly get away with drawing them yourself in the mapPane. Then your polygons would be above them. Or the opposite: you could draw the polygons yourself in one of the higher layers, maybe in floatShadow.



      The problem then is you have to do all of your own drawing, either with a canvas element or with DOM images. And your own mouse hit testing too if they are clickable.



      There aren't a lot of good OverlayView examples out there, but I'll mention one of my own: a little library I wrote a while ago called PolyGonzo, where the polygonzo.js file has the OverlayView implementation. The code isn't great - I threw it together in too much of a hurry - but it may help give you some ideas.






      share|improve this answer

























      • Thank you for the answer. The markers are clickable, and the polygons are drawn by the users and that is why I wanted to go with the google.maps.drawing library.

        – Nicolas
        Mar 30 '13 at 13:15






      • 1





        Bummer. Yeah, the way they put polygons in the overlayLayer makes it tricky. You either have to implement your own polygons or your own markers. No easy solution here. You could implement your own markers and put them way down in the mapLayer, with matching transparent elements in the overlayMouseTarget layer for mouse hit testing.

        – Michael Geary
        Mar 30 '13 at 21:49







      • 1





        Partially transparent markers might be a possible compromise, allowing the underlying polygon to be seen under the markers. Not perfect, but simple with custom .png image(s).

        – Beetroot-Beetroot
        Nov 2 '13 at 16:39











      • @MichaelGeary Thank you very much!! Saved my time

        – blackDelta-Δ
        Jul 27 '15 at 12:34















      56





      +50









      This won't solve the problem, but it will explain why the things you tried didn't work.



      The Maps API uses several layers known as MapPanes in a fixed Z order:



      • 4: floatPane (infowindow)

      • 3: overlayMouseTarget (mouse events)

      • 2: markerLayer (marker images)

      • 1: overlayLayer (polygons, polylines, ground overlays, tile layer overlays)

      • 0: mapPane (lowest pane above the map tiles)

      So the marker images in layer 2 are always above the polygons in layer 1. When you fiddle with the z-index on the markers, you're just adjusting them relative to each other. That doesn't do any good, because they are all in a layer above the polygons.



      What can you do about this? The only solution I can think of is to create your own OverlayView for the polygons or the markers so you can put them in the MapPane you want.



      Are your markers clickable, or are they just static images? If they aren't clickable, you could possibly get away with drawing them yourself in the mapPane. Then your polygons would be above them. Or the opposite: you could draw the polygons yourself in one of the higher layers, maybe in floatShadow.



      The problem then is you have to do all of your own drawing, either with a canvas element or with DOM images. And your own mouse hit testing too if they are clickable.



      There aren't a lot of good OverlayView examples out there, but I'll mention one of my own: a little library I wrote a while ago called PolyGonzo, where the polygonzo.js file has the OverlayView implementation. The code isn't great - I threw it together in too much of a hurry - but it may help give you some ideas.






      share|improve this answer

























      • Thank you for the answer. The markers are clickable, and the polygons are drawn by the users and that is why I wanted to go with the google.maps.drawing library.

        – Nicolas
        Mar 30 '13 at 13:15






      • 1





        Bummer. Yeah, the way they put polygons in the overlayLayer makes it tricky. You either have to implement your own polygons or your own markers. No easy solution here. You could implement your own markers and put them way down in the mapLayer, with matching transparent elements in the overlayMouseTarget layer for mouse hit testing.

        – Michael Geary
        Mar 30 '13 at 21:49







      • 1





        Partially transparent markers might be a possible compromise, allowing the underlying polygon to be seen under the markers. Not perfect, but simple with custom .png image(s).

        – Beetroot-Beetroot
        Nov 2 '13 at 16:39











      • @MichaelGeary Thank you very much!! Saved my time

        – blackDelta-Δ
        Jul 27 '15 at 12:34













      56





      +50







      56





      +50



      56




      +50





      This won't solve the problem, but it will explain why the things you tried didn't work.



      The Maps API uses several layers known as MapPanes in a fixed Z order:



      • 4: floatPane (infowindow)

      • 3: overlayMouseTarget (mouse events)

      • 2: markerLayer (marker images)

      • 1: overlayLayer (polygons, polylines, ground overlays, tile layer overlays)

      • 0: mapPane (lowest pane above the map tiles)

      So the marker images in layer 2 are always above the polygons in layer 1. When you fiddle with the z-index on the markers, you're just adjusting them relative to each other. That doesn't do any good, because they are all in a layer above the polygons.



      What can you do about this? The only solution I can think of is to create your own OverlayView for the polygons or the markers so you can put them in the MapPane you want.



      Are your markers clickable, or are they just static images? If they aren't clickable, you could possibly get away with drawing them yourself in the mapPane. Then your polygons would be above them. Or the opposite: you could draw the polygons yourself in one of the higher layers, maybe in floatShadow.



      The problem then is you have to do all of your own drawing, either with a canvas element or with DOM images. And your own mouse hit testing too if they are clickable.



      There aren't a lot of good OverlayView examples out there, but I'll mention one of my own: a little library I wrote a while ago called PolyGonzo, where the polygonzo.js file has the OverlayView implementation. The code isn't great - I threw it together in too much of a hurry - but it may help give you some ideas.






      share|improve this answer















      This won't solve the problem, but it will explain why the things you tried didn't work.



      The Maps API uses several layers known as MapPanes in a fixed Z order:



      • 4: floatPane (infowindow)

      • 3: overlayMouseTarget (mouse events)

      • 2: markerLayer (marker images)

      • 1: overlayLayer (polygons, polylines, ground overlays, tile layer overlays)

      • 0: mapPane (lowest pane above the map tiles)

      So the marker images in layer 2 are always above the polygons in layer 1. When you fiddle with the z-index on the markers, you're just adjusting them relative to each other. That doesn't do any good, because they are all in a layer above the polygons.



      What can you do about this? The only solution I can think of is to create your own OverlayView for the polygons or the markers so you can put them in the MapPane you want.



      Are your markers clickable, or are they just static images? If they aren't clickable, you could possibly get away with drawing them yourself in the mapPane. Then your polygons would be above them. Or the opposite: you could draw the polygons yourself in one of the higher layers, maybe in floatShadow.



      The problem then is you have to do all of your own drawing, either with a canvas element or with DOM images. And your own mouse hit testing too if they are clickable.



      There aren't a lot of good OverlayView examples out there, but I'll mention one of my own: a little library I wrote a while ago called PolyGonzo, where the polygonzo.js file has the OverlayView implementation. The code isn't great - I threw it together in too much of a hurry - but it may help give you some ideas.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      edited Oct 15 '18 at 22:47

























      answered Mar 28 '13 at 4:27









      Michael GearyMichael Geary

      23.4k74460




      23.4k74460












      • Thank you for the answer. The markers are clickable, and the polygons are drawn by the users and that is why I wanted to go with the google.maps.drawing library.

        – Nicolas
        Mar 30 '13 at 13:15






      • 1





        Bummer. Yeah, the way they put polygons in the overlayLayer makes it tricky. You either have to implement your own polygons or your own markers. No easy solution here. You could implement your own markers and put them way down in the mapLayer, with matching transparent elements in the overlayMouseTarget layer for mouse hit testing.

        – Michael Geary
        Mar 30 '13 at 21:49







      • 1





        Partially transparent markers might be a possible compromise, allowing the underlying polygon to be seen under the markers. Not perfect, but simple with custom .png image(s).

        – Beetroot-Beetroot
        Nov 2 '13 at 16:39











      • @MichaelGeary Thank you very much!! Saved my time

        – blackDelta-Δ
        Jul 27 '15 at 12:34

















      • Thank you for the answer. The markers are clickable, and the polygons are drawn by the users and that is why I wanted to go with the google.maps.drawing library.

        – Nicolas
        Mar 30 '13 at 13:15






      • 1





        Bummer. Yeah, the way they put polygons in the overlayLayer makes it tricky. You either have to implement your own polygons or your own markers. No easy solution here. You could implement your own markers and put them way down in the mapLayer, with matching transparent elements in the overlayMouseTarget layer for mouse hit testing.

        – Michael Geary
        Mar 30 '13 at 21:49







      • 1





        Partially transparent markers might be a possible compromise, allowing the underlying polygon to be seen under the markers. Not perfect, but simple with custom .png image(s).

        – Beetroot-Beetroot
        Nov 2 '13 at 16:39











      • @MichaelGeary Thank you very much!! Saved my time

        – blackDelta-Δ
        Jul 27 '15 at 12:34
















      Thank you for the answer. The markers are clickable, and the polygons are drawn by the users and that is why I wanted to go with the google.maps.drawing library.

      – Nicolas
      Mar 30 '13 at 13:15





      Thank you for the answer. The markers are clickable, and the polygons are drawn by the users and that is why I wanted to go with the google.maps.drawing library.

      – Nicolas
      Mar 30 '13 at 13:15




      1




      1





      Bummer. Yeah, the way they put polygons in the overlayLayer makes it tricky. You either have to implement your own polygons or your own markers. No easy solution here. You could implement your own markers and put them way down in the mapLayer, with matching transparent elements in the overlayMouseTarget layer for mouse hit testing.

      – Michael Geary
      Mar 30 '13 at 21:49






      Bummer. Yeah, the way they put polygons in the overlayLayer makes it tricky. You either have to implement your own polygons or your own markers. No easy solution here. You could implement your own markers and put them way down in the mapLayer, with matching transparent elements in the overlayMouseTarget layer for mouse hit testing.

      – Michael Geary
      Mar 30 '13 at 21:49





      1




      1





      Partially transparent markers might be a possible compromise, allowing the underlying polygon to be seen under the markers. Not perfect, but simple with custom .png image(s).

      – Beetroot-Beetroot
      Nov 2 '13 at 16:39





      Partially transparent markers might be a possible compromise, allowing the underlying polygon to be seen under the markers. Not perfect, but simple with custom .png image(s).

      – Beetroot-Beetroot
      Nov 2 '13 at 16:39













      @MichaelGeary Thank you very much!! Saved my time

      – blackDelta-Δ
      Jul 27 '15 at 12:34





      @MichaelGeary Thank you very much!! Saved my time

      – blackDelta-Δ
      Jul 27 '15 at 12:34













      6














      I know this question is old but for future users I wanna share my approach:



      Shapes with higher zIndex values displaying in front of those with lower values. For this example I am using Polygon but is similar for other shapes:



      var globalZIndex = 1; //Be sure you can access anywhere
      //... Other instructions for creating map, polygon and any else
      polygon.setOptions( zIndex: globalZIndex++ );


      Notice that markers have a method setZIndex(zIndex:number).






      share|improve this answer























      • code example makes it clear

        – Developerium
        Feb 7 '16 at 6:41











      • FIX: setZIndex(number)

        – Zhenya
        Feb 9 '16 at 21:12















      6














      I know this question is old but for future users I wanna share my approach:



      Shapes with higher zIndex values displaying in front of those with lower values. For this example I am using Polygon but is similar for other shapes:



      var globalZIndex = 1; //Be sure you can access anywhere
      //... Other instructions for creating map, polygon and any else
      polygon.setOptions( zIndex: globalZIndex++ );


      Notice that markers have a method setZIndex(zIndex:number).






      share|improve this answer























      • code example makes it clear

        – Developerium
        Feb 7 '16 at 6:41











      • FIX: setZIndex(number)

        – Zhenya
        Feb 9 '16 at 21:12













      6












      6








      6







      I know this question is old but for future users I wanna share my approach:



      Shapes with higher zIndex values displaying in front of those with lower values. For this example I am using Polygon but is similar for other shapes:



      var globalZIndex = 1; //Be sure you can access anywhere
      //... Other instructions for creating map, polygon and any else
      polygon.setOptions( zIndex: globalZIndex++ );


      Notice that markers have a method setZIndex(zIndex:number).






      share|improve this answer













      I know this question is old but for future users I wanna share my approach:



      Shapes with higher zIndex values displaying in front of those with lower values. For this example I am using Polygon but is similar for other shapes:



      var globalZIndex = 1; //Be sure you can access anywhere
      //... Other instructions for creating map, polygon and any else
      polygon.setOptions( zIndex: globalZIndex++ );


      Notice that markers have a method setZIndex(zIndex:number).







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 13 '14 at 14:46









      Manuel LoperaManuel Lopera

      1,41311115




      1,41311115












      • code example makes it clear

        – Developerium
        Feb 7 '16 at 6:41











      • FIX: setZIndex(number)

        – Zhenya
        Feb 9 '16 at 21:12

















      • code example makes it clear

        – Developerium
        Feb 7 '16 at 6:41











      • FIX: setZIndex(number)

        – Zhenya
        Feb 9 '16 at 21:12
















      code example makes it clear

      – Developerium
      Feb 7 '16 at 6:41





      code example makes it clear

      – Developerium
      Feb 7 '16 at 6:41













      FIX: setZIndex(number)

      – Zhenya
      Feb 9 '16 at 21:12





      FIX: setZIndex(number)

      – Zhenya
      Feb 9 '16 at 21:12











      0














      Hello for me A found this solution



      for Create Symbol



      var lineSymbol = 
      path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
      strokeColor: '#181727',
      fillColor: '#50040B',

      ;

      var dashedSymbol =
      path: 'M 0,-1 0,1',
      strokeOpacity: 1,
      scale: 4

      ;

      [![function MakeMarker(pinColor)" + pinColor,
      new google.maps.Size(21, 34),
      new google.maps.Point(0,0),
      new google.maps.Point(10, 34));

      return pinImage;

      ][1]][1]

      FlowMarkersdashed(new google.maps.LatLng(positionorigin[0], positionorigin[1]),
      new google.maps.LatLng(positiondestination[0], positiondestination[1]), myObject[i]['flowfluxphysique'][j]['colorFlux'], dashedSymbol, j);

      function FlowMarkersdashed(latlngOrgin, latlngDest, ColorFlow, Symbol, indexvar)

      var flightPlanCoordinates = [
      latlngOrgin,
      lat: latlngOrgin.lat() + (indexvar) * 2, lng: latlngOrgin.lng(),
      // lat: -18.142, lng: 178.431,
      latlngDest,
      ];
      var line = new google.maps.Polyline(
      path: flightPlanCoordinates,
      strokeOpacity: 0,
      icons: [
      icon: Symbol,
      // offset: '100%',
      offset: '0',
      repeat: '20px'

      // repeat: '20px'
      ],
      strokeColor: "#"+ColorFlow,
      geodesic: true,

      // editable: true,

      map: map
      );



      And For Create a Flow Marker Simple



      FlowMarkers(new google.maps.LatLng(positionorigin[0], positionorigin[1]),
      new google.maps.LatLng(positiondestination[0], positiondestination[1]), myObject[i]['flowfluxinformation'][j]['colorFlux'], lineSymbol,j);


      function FlowMarkersdashed(latlngOrgin, latlngDest, ColorFlow, Symbol, indexvar)

      var flightPlanCoordinates = [
      latlngOrgin,
      lat: latlngOrgin.lat() + (indexvar) * 2, lng: latlngOrgin.lng(),
      // lat: -18.142, lng: 178.431,
      latlngDest,
      ];
      var line = new google.maps.Polyline(
      path: flightPlanCoordinates,
      strokeOpacity: 0,
      icons: [
      icon: Symbol,
      // offset: '100%',
      offset: '0',
      repeat: '20px'

      // repeat: '20px'
      ],
      strokeColor: "#"+ColorFlow,
      geodesic: true,

      // editable: true,

      map: map
      );



      And Finally this is my result



      enter image description here






      share|improve this answer



























        0














        Hello for me A found this solution



        for Create Symbol



        var lineSymbol = 
        path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
        strokeColor: '#181727',
        fillColor: '#50040B',

        ;

        var dashedSymbol =
        path: 'M 0,-1 0,1',
        strokeOpacity: 1,
        scale: 4

        ;

        [![function MakeMarker(pinColor)" + pinColor,
        new google.maps.Size(21, 34),
        new google.maps.Point(0,0),
        new google.maps.Point(10, 34));

        return pinImage;

        ][1]][1]

        FlowMarkersdashed(new google.maps.LatLng(positionorigin[0], positionorigin[1]),
        new google.maps.LatLng(positiondestination[0], positiondestination[1]), myObject[i]['flowfluxphysique'][j]['colorFlux'], dashedSymbol, j);

        function FlowMarkersdashed(latlngOrgin, latlngDest, ColorFlow, Symbol, indexvar)

        var flightPlanCoordinates = [
        latlngOrgin,
        lat: latlngOrgin.lat() + (indexvar) * 2, lng: latlngOrgin.lng(),
        // lat: -18.142, lng: 178.431,
        latlngDest,
        ];
        var line = new google.maps.Polyline(
        path: flightPlanCoordinates,
        strokeOpacity: 0,
        icons: [
        icon: Symbol,
        // offset: '100%',
        offset: '0',
        repeat: '20px'

        // repeat: '20px'
        ],
        strokeColor: "#"+ColorFlow,
        geodesic: true,

        // editable: true,

        map: map
        );



        And For Create a Flow Marker Simple



        FlowMarkers(new google.maps.LatLng(positionorigin[0], positionorigin[1]),
        new google.maps.LatLng(positiondestination[0], positiondestination[1]), myObject[i]['flowfluxinformation'][j]['colorFlux'], lineSymbol,j);


        function FlowMarkersdashed(latlngOrgin, latlngDest, ColorFlow, Symbol, indexvar)

        var flightPlanCoordinates = [
        latlngOrgin,
        lat: latlngOrgin.lat() + (indexvar) * 2, lng: latlngOrgin.lng(),
        // lat: -18.142, lng: 178.431,
        latlngDest,
        ];
        var line = new google.maps.Polyline(
        path: flightPlanCoordinates,
        strokeOpacity: 0,
        icons: [
        icon: Symbol,
        // offset: '100%',
        offset: '0',
        repeat: '20px'

        // repeat: '20px'
        ],
        strokeColor: "#"+ColorFlow,
        geodesic: true,

        // editable: true,

        map: map
        );



        And Finally this is my result



        enter image description here






        share|improve this answer

























          0












          0








          0







          Hello for me A found this solution



          for Create Symbol



          var lineSymbol = 
          path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
          strokeColor: '#181727',
          fillColor: '#50040B',

          ;

          var dashedSymbol =
          path: 'M 0,-1 0,1',
          strokeOpacity: 1,
          scale: 4

          ;

          [![function MakeMarker(pinColor)" + pinColor,
          new google.maps.Size(21, 34),
          new google.maps.Point(0,0),
          new google.maps.Point(10, 34));

          return pinImage;

          ][1]][1]

          FlowMarkersdashed(new google.maps.LatLng(positionorigin[0], positionorigin[1]),
          new google.maps.LatLng(positiondestination[0], positiondestination[1]), myObject[i]['flowfluxphysique'][j]['colorFlux'], dashedSymbol, j);

          function FlowMarkersdashed(latlngOrgin, latlngDest, ColorFlow, Symbol, indexvar)

          var flightPlanCoordinates = [
          latlngOrgin,
          lat: latlngOrgin.lat() + (indexvar) * 2, lng: latlngOrgin.lng(),
          // lat: -18.142, lng: 178.431,
          latlngDest,
          ];
          var line = new google.maps.Polyline(
          path: flightPlanCoordinates,
          strokeOpacity: 0,
          icons: [
          icon: Symbol,
          // offset: '100%',
          offset: '0',
          repeat: '20px'

          // repeat: '20px'
          ],
          strokeColor: "#"+ColorFlow,
          geodesic: true,

          // editable: true,

          map: map
          );



          And For Create a Flow Marker Simple



          FlowMarkers(new google.maps.LatLng(positionorigin[0], positionorigin[1]),
          new google.maps.LatLng(positiondestination[0], positiondestination[1]), myObject[i]['flowfluxinformation'][j]['colorFlux'], lineSymbol,j);


          function FlowMarkersdashed(latlngOrgin, latlngDest, ColorFlow, Symbol, indexvar)

          var flightPlanCoordinates = [
          latlngOrgin,
          lat: latlngOrgin.lat() + (indexvar) * 2, lng: latlngOrgin.lng(),
          // lat: -18.142, lng: 178.431,
          latlngDest,
          ];
          var line = new google.maps.Polyline(
          path: flightPlanCoordinates,
          strokeOpacity: 0,
          icons: [
          icon: Symbol,
          // offset: '100%',
          offset: '0',
          repeat: '20px'

          // repeat: '20px'
          ],
          strokeColor: "#"+ColorFlow,
          geodesic: true,

          // editable: true,

          map: map
          );



          And Finally this is my result



          enter image description here






          share|improve this answer













          Hello for me A found this solution



          for Create Symbol



          var lineSymbol = 
          path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
          strokeColor: '#181727',
          fillColor: '#50040B',

          ;

          var dashedSymbol =
          path: 'M 0,-1 0,1',
          strokeOpacity: 1,
          scale: 4

          ;

          [![function MakeMarker(pinColor)" + pinColor,
          new google.maps.Size(21, 34),
          new google.maps.Point(0,0),
          new google.maps.Point(10, 34));

          return pinImage;

          ][1]][1]

          FlowMarkersdashed(new google.maps.LatLng(positionorigin[0], positionorigin[1]),
          new google.maps.LatLng(positiondestination[0], positiondestination[1]), myObject[i]['flowfluxphysique'][j]['colorFlux'], dashedSymbol, j);

          function FlowMarkersdashed(latlngOrgin, latlngDest, ColorFlow, Symbol, indexvar)

          var flightPlanCoordinates = [
          latlngOrgin,
          lat: latlngOrgin.lat() + (indexvar) * 2, lng: latlngOrgin.lng(),
          // lat: -18.142, lng: 178.431,
          latlngDest,
          ];
          var line = new google.maps.Polyline(
          path: flightPlanCoordinates,
          strokeOpacity: 0,
          icons: [
          icon: Symbol,
          // offset: '100%',
          offset: '0',
          repeat: '20px'

          // repeat: '20px'
          ],
          strokeColor: "#"+ColorFlow,
          geodesic: true,

          // editable: true,

          map: map
          );



          And For Create a Flow Marker Simple



          FlowMarkers(new google.maps.LatLng(positionorigin[0], positionorigin[1]),
          new google.maps.LatLng(positiondestination[0], positiondestination[1]), myObject[i]['flowfluxinformation'][j]['colorFlux'], lineSymbol,j);


          function FlowMarkersdashed(latlngOrgin, latlngDest, ColorFlow, Symbol, indexvar)

          var flightPlanCoordinates = [
          latlngOrgin,
          lat: latlngOrgin.lat() + (indexvar) * 2, lng: latlngOrgin.lng(),
          // lat: -18.142, lng: 178.431,
          latlngDest,
          ];
          var line = new google.maps.Polyline(
          path: flightPlanCoordinates,
          strokeOpacity: 0,
          icons: [
          icon: Symbol,
          // offset: '100%',
          offset: '0',
          repeat: '20px'

          // repeat: '20px'
          ],
          strokeColor: "#"+ColorFlow,
          geodesic: true,

          // editable: true,

          map: map
          );



          And Finally this is my result



          enter image description here







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered May 20 '16 at 12:57









          Mourad MAMASSIMourad MAMASSI

          464812




          464812





















              -1














              Change this method call:



              polygon.setZIndex(google.maps.Marker.MAX_ZINDEX + 1); 


              to this:



              polygon.setZIndex(4);





              share|improve this answer





























                -1














                Change this method call:



                polygon.setZIndex(google.maps.Marker.MAX_ZINDEX + 1); 


                to this:



                polygon.setZIndex(4);





                share|improve this answer



























                  -1












                  -1








                  -1







                  Change this method call:



                  polygon.setZIndex(google.maps.Marker.MAX_ZINDEX + 1); 


                  to this:



                  polygon.setZIndex(4);





                  share|improve this answer















                  Change this method call:



                  polygon.setZIndex(google.maps.Marker.MAX_ZINDEX + 1); 


                  to this:



                  polygon.setZIndex(4);






                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 22 '14 at 12:44









                  legoscia

                  29.4k1185117




                  29.4k1185117










                  answered May 22 '14 at 12:27









                  fixerfixer

                  11




                  11



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f15627325%2fgoogle-maps-polygon-and-marker-z-index%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                      Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                      Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved