Make infoWindow like Google map's default infoWindow that shows info from Google Places

大兔子大兔子 提交于 2019-12-13 01:35:19

问题


We have a Google Local profile (or Google Places) for our business and we have added multiple locations for each store. The requirement is to embed a map in each store page of our website with the accurate location of the store and to display an infoWindow just like it's been displayed from Google's map. Example below:

I have read the API's documentation but I can't seem to find a clear answer as to the way of referencing a store that already exists in the map. If I add the address of the store, I usually have a 2nd marker that is not on the exact location of the store. Example below:

If I add longitude and latitude I get 2 markers again (one on top of the other) but then again these markers do not relate to each other as they have different infoWindows. And one major issue is that by using the Places API I can't get the info just like Google does (I get undefined). Example:

Questions:

  1. How can I really relate (or reference) to the store's location and the Google's Place location and have just one marker with the Google's info in it?

  2. How can I reference to a specific store based on Google's Place profile, which has a business with multiple store locations and link it to the "Store" marker that already exists in the map?

Attempts:

  1. I tried locating the store based on PlacesService and nearbySearch with a keyword of the store name. Example here. The problem is that I have 2 markers on the map if I zoom in at maximum level.

  2. One more issue is that I have 81 stores and it's hard to hard-code the coordinates for each store in each webpage. So, since I have the address in each page I tried geocoding to get longlat. This wasn't very accurate way because it seems that geocode snaps to a nearby area and not exactly on the store. Example here.

  3. I tried PlacesService with the reference string for identifying the store's location based on Google's Place profile. Example here. However, there's not an easy way to retrieve the reference string for each store and another issue is that I need hardcoded coordinates to center the map in the area of the store (too much work for 81 stores).

Expected solutions/suggestions:

I would like to fully utilize our Google's Places profile that includes all the stores info. BTW, each store now has a Google+ page created automatically by Google. I would like a suggestion on how to utilize the automatically created Store marker (like in 1st picture) and have the exact same infoWindow like Google's default (1st picture) with some sort of a reference ID from our Google's Places profile.

I apologize for this long question but I had to further explain all my attempts.

来源:https://stackoverflow.com/questions/23023451/make-infowindow-like-google-maps-default-infowindow-that-shows-info-from-google

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