How to prompt user for place using Google Maps in javascript? - javascript

I am new to Google Maps and still new to Javascript. I need to have a user select a location on a map (using Google Map) and retrieve the corresponding town, country, latitude and longitude. If timezone is available too, that would be great.
I can't find an operational code example. Does anyone have one to share? Thanks.

The sample code provided by Google at http://code.google.com/apis/maps/documentation/javascript/examples/event-arguments.html gets a LatLng from a mouse click and puts a marker on a map. (Just view the source code to see the sample code.)
The sample code provided by Google at http://code.google.com/apis/maps/documentation/javascript/examples/geocoding-reverse.html takes a latitude and longitude and determines the location via reverse geocoding. (Again, view source code to see the sample.)
Sounds like your functionality is basically parts of each of those samples and fusing them.
You might want to check out the Events documentation and the Reverse Geocoding documentation if you run into any problems (or even if you don't).

Related

Is it possible to search Google Images using latitude and longitude for a web app?

I'm working on a web application to find images taken in a given location. I'd like to be able to do this using the latitude and longitude retrieved from geolocation to match geotagged images in Google images.
Is this possible? I've searched around a bit; it seems it's possible to search Flickr by lat/long, but I haven't found anything that indicates I can search Google images by lat/long. I can search by place name, but I'm looking for something more accurate than that.
Thank you in advance!
After looking through Google's Custom Search API (the Google Image Search API was deprecated and rolled into it), it looks like there isn't a way to search by geolocation.
Flickr might be your best bet since it's more open.
It's possible to retrieve images and photo taken at a certain place (therefore find a place by lat-long data) with Google Earth. While you are on a specific place, you can add additional layers (by default) including photos on your location.

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

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:
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?
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:
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.
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.
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.

How to use new Google Maps coordinates (GMS) with LatLng?

I'm using a Google Maps object on my website to display different locations I've been to. I always used the coordinates (GGG) from the old Google Maps to set a new marker to my map. But with the new Google Maps I only get GMS format.
Before: 51.055207,10.524902
After: 51° 4.193', 8° 41.807'
My problem is, that I'm not able to use google.maps.LatLng to set a marker position anymore. If I'm typing in the new format, my map crashes and no marker is shown.
Is there another method I could use? Or do I have to convert the positions to GGG format?
Use the decimal format that you used to use. The API has not changed with the visual refresh of the maps so everything should work as usual. If that's not working, please provide your code so we can help troubleshoot.

Highlighting custom locations on map

I would like to do something like what is shown in the screenshot - http://themanyfacesof.com/wp-content/uploads/2010/03/map.png
I want to be able to highlight certain areas on a map using PHP as a server side technology and jQuery(preferable) on client side with some tooltip functionality. Is there anything available or any idea how this could be achieved with the complexity involved?
Completely client-side solution: http://jvectormap.owl-hollow.net/
Look into using Google Maps for this. You can overlay lines and polygons which effectively means you can do anything - for example Loughbrough University does this.
A good way to start is to
Log in to Google
Go to Google Maps, then to my maps and create a new map
Draw polygons and line using the tools provided
Right click and copy the link for Google Earth, visit this link but change the output to KML output=kml. KML is just like XML
You now have a file with the exported polygons and lines that you drew. You can then re-draw these onto a Google Map programmatically
I did this the other day to get some rather complex polygons drawn onto a map without having to trial and error the latitude and longitude coordinates for them.
Hope that helps.

Google Maps API - How can I enable 'Points of Interest'?

I've seen some sites, that use Google Maps, have the ability to show 'Points of Interest' on the map. Similar to what Google Earth does.
Here's an example of what I'm talking about: http://i.imgur.com/5OCor.jpg
How can I do this? :/
As far as I know, Google Map does not have a 'Points of Interest' feature for you to enable.
But you always can do it on your own. First of all, you have to obtain a POI database, e.g. Open source POI database? - Stack Overflow
Next, select the POIs visible in the viewport. Then add them to the map using GMarker. You also have to add or remove the POI as user pan and zoom the map.
As you can see this requires fair bit of programming. Google Earth has already packaged this into a great application. But this isn't available in Google map API (that I know of).
One possible source of POI data is http://compass.webservius.com - it's a REST API allowing access to a database of millions of businesses in the USA, searchable by business type (industry code), latitude/longitude bounding box, etc.

Categories

Resources