Capture Coordinates in Google Map on User Click

前端 未结 5 546
感情败类
感情败类 2020-12-13 03:35

I\'m using this code to capture the co-ordinates when user clicks on the map by using below event listener:

google.map         


        
5条回答
  •  半阙折子戏
    2020-12-13 04:33

    You're talking about the Point of Interest icons that Google puts on the map.

    Would it work for you to remove these icons entirely? You can do that with a Styled Map. To see what this would look like, open the Styled Map Wizard and navigate the map to the area you're interested in.

    Click Point of interest under Feature type, and then click Labels under Element type. Finally, click Visibility under Stylers and click the Off radio button under that.

    This should remove all of the point of interest icons without affecting the rest of the map styling. With those gone, clicks there will respond to your normal map click event listener.

    The Map Style box on the right should show:

    Feature type: poi
    Element type: labels
    Visibility: off

    If the result looks like what you want, then click Show JSON at the bottom of the Map Style box. The resulting JSON should like this this:

    [
      {
        "featureType": "poi",
        "elementType": "labels",
        "stylers": [
          { "visibility": "off" }
        ]
      }
    ]
    

    You can use that JSON (really a JavaScript object literal) using code similar to the examples in the Styled Maps developer's guide. Also see the MapTypeStyle reference for a complete list of map styles.

提交回复
热议问题