Can I change the marker in a Google Maps embedded map (iframe)?

两盒软妹~` 提交于 2019-12-03 14:52:52

问题


I know I can do it with the Google Maps API, but do you know if there is a way to change the marker in an embedded Google Map?

I want to replace the default "A" button for a "B" button or the marker with just a dot in the middle.


回答1:


I haven't played around with embedding Google Maps before (I generally go straight to the API for stuff like this). I tried a couple of approaches:

  • I figured maybe the embed syntax would be the same as the static maps api. So I grabbed a static maps URL, copied the markers param from that and tried sticking it into the iFrame URL. This didn't work so much.

  • I created a Google MyPlaces and customized the marker to use the one your provided. This created a Test map which had the appropriate marker icon. I then grabbed the embed code and stuck it on a test page and voila!




回答2:


Actually I had the same problem but didn't use any of the methods above and thought I share:

If you only want a marker as I did but don't want to use API then simply fool google into thinking you want a route planned using the GET tags "saddr" and "daddr"

"saddr" defines your start location (post code , street name+ number, whatever)

ONLY define saddr and leave out daddr and google maps will by default still show the marker for "A" (your start location) exactly where you want it , all in iframe without API.



来源:https://stackoverflow.com/questions/1175691/can-i-change-the-marker-in-a-google-maps-embedded-map-iframe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!