Address breaks map display, why?

走远了吗. 提交于 2019-12-11 09:03:52

问题


Currently I am generating a Google static map by inserting an address through PHP insertion like this:

<img src="http://maps.googleapis.com/maps/api/staticmap?center=<?=$gmapadd?>&zoom=14&size=300x200&markers=color:blue|label:A|<?=$gmapadd?>&sensor=false">

Now here is an example output from this same script that displays properly:

<img src="http://maps.googleapis.com/maps/api/staticmap?center=11555+Central+Parkway+Jacksonville+FL+32224&amp;zoom=14&amp;size=300x200&amp;markers=color:blue|label:A|11555+Central+Parkway+Jacksonville+FL+32224&amp;sensor=false">

Here however, the output/address breaks the API (doesn't report an error, it just doesn't show the map), but I don't see the formatting problem or why it would break the map display. Also, if I enter this address into Google maps 5000-18 Hwy 17 #82 Orange Park, FL 32003 it does recognize it and display properly?

<img src="http://maps.googleapis.com/maps/api/staticmap?center=5000-18+Hwy+17+#82+Orange+Park+FL+32003&amp;zoom=14&amp;size=300x200&amp;markers=color:blue|label:A|5000-18+Hwy+17+#82+Orange+Park+FL+32003&amp;sensor=false">

回答1:


The "#" is not legal in a URL. It needs to be encoded:

http://maps.googleapis.com/maps/api/staticmap?center=5000-18%2BHwy%2B17%2B%2382%2BOrange%2BPark%2BFL%2B32003&zoom=14&size=300x200&markers=color:blue|label:A|5000-18%2BHwy%2B17%2B%2382%2BOrange%2BPark%2BFL%2B32003&sensor=false



来源:https://stackoverflow.com/questions/16321218/address-breaks-map-display-why

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