I currently have a service area system based on zipcodes, customers would enter an address(zipcode) and it would return the available service times for their service area (a service area can have multiple zipcodes), what I need to do now is instead of using zipcodes to create service areas I need to use a boundary system where I can draw polygons on a map and when customers enter an address we would geocode it and compare against the service area and return appropriate service time, a system like this would be more accurate because the problem I have now is that zipcode boundaries are of very different shapes and it is impossible to make an accurate service time map. I'm having problems thinking of an easy way to accomplish this.
to get you started:
Google Maps tutorial
After researching deeper on this topic, I found what I was looking for!, I could use the ray-casting algorithm to spot a point(coordinates) inside a polygon, the polygon's coordinates I can easily get from Google maps, In essence what I will be doing is:
Make a Google maps area selector to build polygons.
Save polygons point coordinates array to database.(as service region/area)
Geo-Code customers addresses and save to DB as well (First time will pull from Google maps and save on DB for future use).
4.Use the Ray-Casting Algorithm to loop through all the "polygons" until it returns true and we would know to what polygon the address belongs to, if it returns false then we know we don't service that area.
References:
Raycasting algorithm with GPS coordinates
http://rosettacode.org/wiki/Ray-casting_algorithm
Related
I'm looking for a solution to get data to create a simple roads-only map.
Within a small area specified by lat/long I need data that allows me to draw custom lines between given street coordinates (start and endpoints are basically enough and only from major streets). Coordinates from intersections are also fine to connect those with my custom lines.
Another approaches would be to get all the major street names within the specified area via reverse geocoding and then - somehow - get coordinates for each of this streets.
There was a similar request a couple years ago:
Get street graph for a game using Google Maps API and I'm wondering is it still a big deal to achieve this kind of technical information in a simple way?
EDIT:
I researched the topic but no result gave me the satisfaction I was looking for. For instance Google's Directions/Roads API are both depending on routes. OSM/Google Maps API are filled with information around a specified geo location but without any technical data I need. To be simple: An Array of intersection/street-point coordinates (are they even called coordinates?!).
I think I'm lost - or even stuck - in terms of my own search phrases. I'm not looking for a copy & paste snippet more like a direction or some hints where to focus next or how it is done.
With the clarification of geocodezip's comment I've found the following related question:
How to get all roads around a given location in OpenStreetMap?
This fully suits my demand to get specific road information within a certain location using OSM instead of Google Maps API.
Many thanks
Hey guys i'm developing a specific android app which has a BigData of locations all over a country,i want to filter those locations due to user's current location with a radius.
To clarify my purpose my user is a car driver that chooses a random road on Google Map by specifying the start and the end point using Markers then i draw a road between those points using Google API
What i want to do is getting the locations from my database that lies on the selected road only so i thought of filtering my database locations due to user's current location and give it a radius which is the distance on the road(the distance between the two Markers chosen by the user) and start showing them on the map.
Note:I thought of comparing the locations in my database with the user's current location, If it is shorter than the radius(the distance between the two Markers) then i will add it to my filtration result
but i think it's a mess i have a BigData and it would take too much time to compare.
Is there any algorithm or API that Google Maps Provides for this problem that i can use to filter?
even if it's written in a web programming language i can create a web service to handle it and send it to my application.
Use KD-tree K nearst neighbours, to filter the points that are away from the car. and that's log N time complexity. but inserting into the tree is N*log N
I have find a solution for my problem
In my application i'm using Firebase as cloudbacked and fortunately it has a library that performs GeoQueries called GeoFire it's documentation is here
It can create a query of all saved locations in Firebase due to a specific location by a radius in milliseconds which is what i really need
I am working on a quote calculator that will generate a quote based on mileage between various locations (amongst other conditionals). Up until two days ago, I had planned to use Google's Distance Matrix service until I discovered:
Display of a Google Map
Use of the Distance Matrix service must relate to the display of information on a Google Map; for example, to determine origin-destination pairs that fall within a specific driving time from one another, before requesting and displaying those destinations on a map. Use of the service in an application that doesn't display a Google map is prohibited.
I had hoped to use only the services that I require:
- Distance by Road Measurement between up to three different locations
- Address Autocomplete Service usable on an input box
- Accurate, reliable service that can provide multiple different routes to create an average distance
I know there are other methods available for this, but I doubt many can be as accurate and reliable as Google, I've found it challenging to find anything comparable to Google Maps for the purposes I require.
So, unless you guys can point me to something that I can use, my only option is to use a Google Map where I don't need it, adding additional loading time and altering the UX design I had planned.
Are there any free services available for what I require (preferably with a JS API)?
On a slightly different note
If I do use a Google map, would it have to be displayed immediately, or could I hide it and add an option to 'Show On Map', and have it .slideToggle revealed?
Unfortunately for the Distance Matrix API, Google strictly says you NEED to display the map in your application:
Use of the Distance Matrix API must relate to the display of information on a Google Map; for example, to determine origin-destination pairs that fall within a specific driving time from one another, before requesting and displaying those destinations on a map. Use of the service in an application that doesn't display a Google map is prohibited.
http://developers.google.com/maps/documentation/distancematrix/#Limits
However, what I think is more useful for your need is Google Directions API. The directions API allows you to cover your requirements.
The total distance is returned in the JSON object from the request.
You can select upto as many different locations to find distances between using the Waypoints in your search request. The distances between these locations are then returned in each "leg".
You can obtain the average distance from multiple different routes to your destination by specifying the alternatives parameter in your search request to true. See: http://developers.google.com/maps/documentation/directions/#RequestParameters
Best of all, there is no requirement from Google to display the Google Map in your application when using this service.
I should also mention the drawbacks to this service, if you choose to use it.
The request time it takes to process your request will be slightly longer than if you were to use the Distance Matrix API.
You'll have a lot of unneeded data in the return object, for instance the individual "steps" of the route in the returned json object is not necessary based on your application requirements.
Given the drawbacks, I'd still highly recommend looking into the Directions API for your application.
I don't know if Google Static Maps count as a map, but it should, since it's a Map and from Google.
You could calculate the route and then show it as an image from Static Maps. No extra map loading times required. Only one image.
https://developers.google.com/maps/documentation/staticmaps/#Paths
Many developers have been able to do this with the Bing Maps REST routing service http://msdn.microsoft.com/en-us/library/ff701705.aspx. It requires a bit more development but works well. Here is an example: http://code.msdn.microsoft.com/Bing-Maps-trip-optimizer-c4e037f7
Streetmap and arcserver can solve a vehicle routing problem but it's not free. Read more here: http://www.esri.com/data/streetmap.
I have been using Google maps api to get customer to a specific location using a constructor like this
new google.maps.LatLng(42.999, 54.000);
With the exact longitude and latitude as the arguments. What I want to do now is not use the lat, long option and use a keyword like rest area that would bring up the closet rest area. I am not quite finding it in Google map api here https://developers.google.com/maps/documentation/javascript/reference
Can some one help me come up with a constrctor that can take a key word and locate the nearest one in googLe maps.
You're going to have to use the google geocoding API.
Basically you do a request to google with a search string and it returns an object containing the long/lat for areas it may have found... There's a lot of options in there and you can do fairly neat tricks which are already carefully explained by google themselves.
https://developers.google.com/maps/documentation/geocoding/
There are some limitations to the # of requests you can make per-day. To keep this to a minimum you can ofcourse make a server side script that pre-fetches results for things that will be re-used (for example the long/lat for office location of a large enterprise which may have a dot on a map on the website...).
Simplest way would be to make a json request with a few parameters and parse the return json in js, like getting the long/lat of the first result returned.
If I understand correctly, you want to use keyword search for things around a particular location. I would suggest using the Places library of the Google Maps API:
https://developers.google.com/maps/documentation/javascript/places#place_searches
This allows you to search by category or by keyword over Google's datastore of 10s of millions of Places.
I am building a JS application which uses google maps and needs the ability to have polygons over the states (the same shape as the state) to which colors can be applied. Something like this:
http://econym.org.uk/gmap/example_states4.htm
I can get something set up similar to that, but I don't have XML or data for any other regions.
What I'd really like is to be able to call a webservice with a given state, country, region, etc. and retrieve a series of lat/long coordinates laying out the given region. I've done some initial research but haven't found anything that seems to be up to task.
Can anyone recommend a solution?
Here is a KML of all US states and capitals. You can extract the states boundaries from that file or just use the KML itself. USA States KML