Highlighting cities with google maps - google-maps

I've recently discovered geolocation, it is a wonderful and fun little feature.
I've figured out how to show somebody's location on a map with a little pin and how to fetch the different parts of their address from the delivered data.
One thing I want to do with all this though is given somebodys location to then highlight their city.
I know that now with google maps if you type in UK postcodes or Japanese cities this can be done, however it gives a very difficult to see outline around the location. It doesn't fully shade it.
My ultimate goal is to shade somebodys city a different colour depending on certain variables, the actual google maps content beyond the basic 'this is where the city is' is unimportant (working out these variables and colours is of course a different area and not the purpose of this question).
So...sorry for my poor English here. But I woder. Is there anyway, given a certain input which on default google maps would give the outlined administrative division, will shade the city a given colour?
Bonus points if you can do more than one city at once (ultimate goal- show their surrounding cities as well as their current city)

I'm doubt you can do it for google map as there seem no way to retrieve google map boundary data. The alternative that I can think of is the use of OpenStreetMap with Kartograph library. This possibly could give you a solution, but you need to manually generate the border out from the OpenStreetMap and color it using the Kartograph library.

Related

Style Country - Google Maps API

I made a google styled map and now I want to add more features to it. The feature I'm trying to add is a way to style specific countries. I want to let my program select a country and then have that country appear differently on the map and stand out.
This is challenging because there are polygon ways to do this, but that would mean it is hardcoded and the country can't change. I want to be able to use this feature on different countries.
Thanks
I don't know of a way to do this with styles; I think you'd need to generate map tiles with countries coloured and overlay those map tiles on top of what you have already.

Grouping registering users into metro areas

I have to group all users registering to my site into metro areas. A metro area is defined a proximity to one of the world's 100 most populous cities.
In my proposed solution the user will be presented with 2 dropdowns. One for country and one for cities. That seems like the best UX.
I was also thinking about using html5 browser location API to pre-select some locations on the dropdowns.
Has anyone done something similar before and how did you approach it?
sub question: how would you store this data
ip-geolocation is often not extramly exact.
I would force user to enter country, city and zip.
And pre fill form with data from browser location api.
In database i would store country, city, zip, and lat long.
Find matching city + zip by lat long and backword is very easy with google geocoder api.
https://developers.google.com/maps/documentation/geocoding/
Then you only needs the lat long values of big citys for search in area. Easyes is to search in squre not in circle. But if you realy needs a cirty, you have to use a databse with gis functionalety. http://postgis.refractions.net/
I would not use geolocation. It doesn't always work the same in all browsers and isn't always reliable for every situation.
I have done something similar and I used area code. Some big metro areas have overlapping area codes but if you use the major area code for the metro areas you can find a good way to attack this. Some states only have several major area codes.... some go up much higher but you know that the more area codes, the more populated the area is (typically). The more area codes attached to a metro area could be used as another factor to determine populous cities.
Most users might not want to give city or zip but will give an area code on registration. You can assign area codes to states and also area codes to metro areas.
This map should help if you decide to approach it that way as an extra value
http://www.nanpa.com/area_code_maps/ac_map_static.html

Accessing google maps area coordinates (suburb boundaries)

I'm trying to show some data about Australian suburbs. 'Suburb' is the term that Australians use to describe an area, if you are from the rest of the world think post code or something similar.
I'd like to be able to get access to the area boundaries that are already in the map. These are examples of the kind of boundary that I'm talking about:
Marrickville, Sydney (2204): http://goo.gl/maps/QYRhx
Clapton, London (E5): http://goo.gl/maps/3an2Y
I want to be able to draw the boundary on the map, draw multiple boundaries on a map (e.g. show which areas make up the 'inner west'), shade the areas to indicate their vaue of something or other. Generally do stuff with them.
This question asks about how to get boundaries that are drawn manually, but I want to access the ones that already exist.
This question asks a similar question, but it isn't answered.
This question is similar, but the responses suggest using shape files, not getting them directly from Google.
I've also tried the maps styling wizard, and whilst the administrative, neighborhood boundary is what I need to show, it doesn't seem to be able to affect the map.
I've looked in the api docs to no avail. Does anyone know if this is possible?
No, it isn't possible.
The area boundaries feature is not (yet?) implemented in the API.
If you explicitly need data from Google then I can't help you.
But if you just need data on Australian suburbs and don't care where you get it from (and if you happen to be interested in SA or NSW) then you can get GeoJSON or KML for SA from data.sa.gov.au/data/dataset/suburb-boundaries and for NSW from data.gov.au/dataset/nsw-suburb-locality-boundaries-psma-administrative-boundaries.
You might find others at data.gov.au/dataset too, I haven't searched that much.

How do I obtain the coordinates along GMaps directions?

I want to create an online map for a hiking trail, and I have been using my smartphone to collect coordinates from it.
I have many questions regarding what's good practice when it comes to making such tracks, but for starters: it would look much neater if I could edit the readings so that they are right on top any roads in Google Maps. How can I achieve this?
EDIT: I want to find the coordinates that will make a track along a road look exactly as if I'm using snapping/directions even when I'm not.
I've tried tools such as QLandkarte GT and Viking, and with the latter I was able to manually remove excess coordinates and move the remaining ones so that they're exactly on top of roads (inside Viking, using OpenStreetMap). However when I load the edited .kml-file in Google Maps, the roads seem to be in slightly different places and the result is hardly better than before editing.
I tried using the hack that exports GMaps directions as .gpx, thinking I could insert Google's own coordinates along the roads. But the exported file only had coordinates at the turning points with straight lines between these.
QLandkarte GT supposedly has a snap-to-road feature (see answer in link), but I haven't found it and I also don't know how to obtain a vector map of the area.
Then there's Google Earth which people seem to use for this, but again I can't find any track editing features (in the free version).
In short:
How do I edit my existing tracks so that they match roads in GMaps...
OR
How can I obtain new tracks representing roads in GMaps...
...so that the resulting track is as smooth as Google's own directions or other professional GPS-data, when displayed in GMaps?
It seems like it's possible to get these coordinates from Google Maps after all, exporting the directions polyline. I'm not sure how, it seems to involve adding the parameter output=dragdir to the link.
Anyway there's a tool called GPS Visualizer that can create a .kml-file with the wanted coordinates.
Edit: Will accept my own answer as long as it's the only one, but I would still like to know more.

How to get the width of a road through Google Maps API

I need to find the width of roads in Google Maps.
Google Earth can't be used as it doesn't support Linux.
Streetviews cannot be used, since it is not available in the area I live.
This link: http://osdir.com/ml/google-maps-js-api-v3/2011-05/msg00666.html suggests the method of finding the distance between the two ends of the road by knowing the coordinates of both sides.
Therefore the first question is as in title.
BTW, I have managed to display the "route" between the two coordinates already on the maps.
The type of the map can be set to "satellite" view through the API.
Does that affect the distance and coordinates that'll be fetched?
All this stuff about getting points across the street from each other is further complicated by the fact that sometimes the geocode returned will be a ROOFTOP geocode--likely meaning the centroid of a building--and other times, it is RANGE_INTERPOLATED which suggests that it will be not very precise. See http://code.google.com/apis/maps/documentation/javascript/reference.html#GeocoderLocationType. In either case, it won't be the edge of the road.
It may be sobering to look just how far from the road Google Maps may put the marker for an address: http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=4+Clinton+Drive,+Englishtown,+NJ&aq=&sll=40.299985,-74.290066&sspn=0.009426,0.015213&gl=us&ie=UTF8&hq=&hnear=4+Clinton+Dr,+Englishtown,+New+Jersey+07726&t=h&z=16
In short, unless your use case can tolerate a pretty wide error bar, I think it's safe to say that this just isn't going to work, at least not without considerable resources at your disposal.
Google Earth web plug-in is not available for Linux, but if you don't need it to be a web page, then you can try working with Google Earth app, perhaps. It works on Linux.
If your use case is for a reasonably narrow geographical area, there may be data available elsewhere. But getting this from Google Maps API v3 is unlikely to be a very good option.
(As always when I give a "I don't think this is feasible" answer, I'd be happy for someone to come along and prove me wrong.)
I'd look at the coordinates of individual houses. If house numbers are arranged such that n+1 is on another side than n, the distance between the two might tell you something about the width. But I don't think there's an API for that...
Here's the NON API solution i thought of,
In my country , roads named with different code names like "A3" , "B354", "C6".
"A" is for main roads. Most of the time width of the road is consistent as per road code. Therefore we can use road code to get the width of the road. I don't know if this works for your country.