0

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.

CodeArtist
  • 113
  • 1
  • 1
  • 5
  • [**See**](http://stackoverflow.com/questions/13318812/google-map-is-a-lat-lng-within-a-polygon/13325478#13325478) which uses php server side to locate point in polygon.It also can be implemented in javascript – david strachan Jan 15 '14 at 13:24

2 Answers2

0

to get you started: Google Maps tutorial

user2930100
  • 346
  • 4
  • 10
  • the technology is not a problem, what I need is the concept... I could use google maps or mapquest or bing maps, I need to know if I need to group geolocations of the service area etc... – CodeArtist Jan 15 '14 at 04:58
  • I know for sure you can draw clickable polygons on top of Google or Bing maps. all you need to know is the list of coordinates to create the polygon. I once made a windows forms application where you could just load up a map and click on different points to create a polygon and then it would save the clicked coordinates to the database. – user2930100 Jan 15 '14 at 05:04
  • For Google Maps, you can use the map 'click' event to capture clicking places on the map. Google has a tutorial for this (scroll to Accessing Arguments in UI Events) : https://developers.google.com/maps/documentation/javascript/events – Andrew - OpenGeoCode Jan 15 '14 at 16:42
0

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:

  1. Make a Google maps area selector to build polygons.
  2. Save polygons point coordinates array to database.(as service region/area)
  3. 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

Community
  • 1
  • 1
CodeArtist
  • 113
  • 1
  • 1
  • 5