I have 100K+ lat/longs in a SQL database, and I want to plot them on a google map. The user will input an address to find points close to that address. How should I do this? I have the map working, with the ability for the user to enter an address and have the map center on this point. Just need to add the pins.
I'll be building the front end in JS, and any backend needs in PHP.
Lets start with the search for address, I would use the Google places API. This will allow you to localise your results and get the coordinates of the place in question.
Once you have the coordinates I would head off to the server to do a lookup, if you are using MySQL you can use their spatial extensions which have some handy ways of indexing things spatially.
You say you have 100k items, obv there is NO way that you can send all of them to the frontend to display on the map, you will need to limit your result set or else the users browers will cry tears of blood as it tries to render and handle all of them. You can have a look at the Google Maps Marker Clusterer for a nice way of displaying a high density of markers.
Related
I want to fetch locations (just the address. No coordinates) from my database (mysql) and pin them on google map using markers
I come from China, so I use Baidu map. Talk about my development process: the request of Baidu Maps API incoming address, API will return to the coordinates, the coordinates of the third party jquery. Similar picture effect enter image description here
Using my android app, I am taking the current location of the user in a regular interval and displaying it on a Google map as marker using,
$map->addMarker($row['lat'],$row['lng'],$isclickable,$title,$info);
Please help me draw a route joining these markers.
One more thing, I am using Location managers Network provider for fetching the coordinates, so most of the points(latitude, longitude) are off the road. Is there any way to get it properly on the road?
Hi I have a database with a list of contacts in which I am displaying onto a page in a list.
As part of this result set I have a post code, is it possible to generate a google map from that postcode and display it as part of the result?
If it is can any one help me get started?
You can use the post code as the location for your map and google will usually be able to find it.
For example, using the static maps API, the following url will give you a map for the zip code 92117 (which is in San Diego, CA):
http://maps.googleapis.com/maps/api/staticmap?center=92117&size=400x400&sensor=false
You can also do something along the lines of what primehunter326 was suggesting and reverse geocode using the javascript API. Which approach is best depends on what you are trying to do.
Start here for info on how to use the various Google Maps APIs:
http://code.google.com/apis/maps/index.html
Yes it is possible. The basic idea is that you use geocode to get longitude and latitude coordinates for the address. You can then use javascript to display a map on your page with all the points as markers. I'll try to find a link with that goes over it in more detail.
Here is a link which goes over geocoding
You'll need an API key in order to use their services, here
I have been looking through the documentation for the API and not sure if it is possible to list multiple select stores near the submitted address.
Ultimately something like the following website: http://www.evolutionofsmooth.com/locator/
It seems like they have each location stored in a db but I can't see it that likely since it would be pretty huge to do something like that.
Any ideas?
They probably did store all the shops in a database. They saved the latitude and longitude of each shop. Then they load, via AJAX, all the shops into the google map. Google maps has a tutorial for creating a storelocator.
Google maps api v3 has a function called ClientLocation this can, on base of the IP-address, return the current position of the user viewing the google map. This way the closest shops can be highlighted or put on top of the list.
Hopes this will help!
I am the owner of a business that is building a new website application. My partner is the programmer who is doing the development and neither one of us has any real in-depth experience with Google Map API or it's polyline/polygon area capabilities.
We need an easy way to capture inputs within our user admin area where our locations can enter their service coverage area info i.e. 1st street north of Jones blvd, or a 5 mile radius from the location address, etc. and have the Google Map API plot the polyline borders.
Then, visitors to our site need to be able to see this info when they view the google map for one of our locations and also see if their service address falls within that service area or not. We then need to set a flag somehow to trigger a notification to the visitor that their address is not eligible for service or delivery.
If anyone can assist us with this (example php code to interface with the suggested APIs would be preferred and ideal as we simply don't understand the complexities of the Google API, the polyline coordinate capture tool, etc), it would be greatly appreciated, as we have struggled to figure out how to create this in php and more importantly how to integrate it into our existing site.
Update: Thank you for your answer CodeMeIT...how do recommend we capture these longlats in our sql database...i.e. what is the field format or type and do we need to have separate fields for long and lat, and how can we standardize for all locations, i.e. how many long and lats are needed to create a polygon area, as we want to be able to have our location managers input this info for their own locations from their user login areas.
Draw polygon on map
You can draw polygons that covering your service area on google map. Those polygons are defined by a set of latlongs that you can collect from a google earth and sasve them somewhere. Once you had all the coordinates that can cover your each service area, you can see the link to find out how to draw them on google map
Google Map polygons Sample
Check if user is within service area
If the user had address information entered or stored somewhere, you can take the address to google map geocoding service to find out the address's latitude and longitude.
Google MAP Geocoding Service API
After getting the address' coordinate, the code can check if the coordinateis within any bound of the polygons of your service area. If false, that is out of service area.
PHP for checking point in polygon