How can I display a different icon for markers that fit wthin different categories?

℡╲_俬逩灬. 提交于 2019-12-02 00:07:48

Make an object var iconSrc = {}

Then, match categories to icon images to it.

iconSrc['Dial-a-ride'] = 'http://labs.google.com/ridefinder/images/mm_20_red.png';
iconSrc['American Legion'] = 'http://labs.google.com/ridefinder/images/mm_20_green.png';
...

when adding a marker, replace the icon image source with the new variable:

icon: iconSrc[locations[i][2]]

Here's a jsfiddle, the navigation is tough in the small pane so I moved the checkboxes to the top. http://jsfiddle.net/DA92S/1/

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