I'm currently putting together a map that shows the jurisdiction of different offices. I'd like to be able to draw the borders on the map (already done in a PNG), and allow users to either click the map roughly where they live, or type in a postal code. This will lead to the office web page closest to them.

I have two ideas in mind, but thought I'd ask to see if either (or another) way is the best answer:

1) Break the PNG into an image map, and then write the php to determine what region the postal code is within. No idea how to deal with postal codes though.

2) Use Google Maps API: Draw the borders (again) or draw polygons, which allows for the user to zoom in, find their actual location, and type in their postal code on their own. However, how do I know where the postal code falls under my borders? How then, does it redirect to the correct page?

If you've got any ideas (or different methods of doing it), I'd love to hear them! Thanks!

Recommended Answers

All 4 Replies

Thanks for the reply!

So would you say Google Maps is the better of the two then? Why not the image map?

Member Avatar for diafol

The geolocation ensures that the user will be placed on the googlemap without any need to enter anything. Without the 'address' from the postal code, how could an image map decide where to place you? I'd say, your best bet would be to cut up the country/region in your GoogleMap into polygons (based on lat/long coords), using a coloured translucent overlay (max 4 or 5 colours as used in atlases), you should be able to sort this out without much hassle.

If auto-geolocation doesn't work, just have a textbox for postal code which should then centre the map around this marker (polygons intact!).

It should be noted that postal codes do not describe areas that will fall in line with your polygons (well, I assume not), so there will be a margin of uncertaintly at the borders of your zones.

Image maps are great for what they are - for static images. They aren't brilliant for interactive maps - more like a headache! Trying to keep track of all that coordinate data - no, not nice.

2 things:

The coordinates are going to have to be tracked anyway, to see which region the person is in. I don't see how Google Maps is less work that way, as I still need to develop a "point in polygon" function to determine if the tracker is within one of the polygons.

Also, yes - auto-geolocation will lead us to where they are currently, but the person may be requiring the service in a region they are not currently in. Say, for example, they are viewing the map from somewhere other than home, or they need the service to be booked in a different city.

Our users are not very technical, and I worry that this will mislead them, so I wasn't planning on using geolocation. And yes, I realize I made it sound like we always wanted to know where they currently were in my OP. My apologies.

You've given me a lot to consider. Thank you. I'm glad to hear the solutions weren't way out there, and that no one seems to have a third, much more obvious answer.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.