node.js - How to get a list of cities surrounding a city of interest (surrounding suburbs) on google maps api -


we need find , list cities touching border of city of interest - example, search ryde, nsw - trying find list of every city touching border of ryde, nsw.

we tried radius search, example - if choose 3km standard radius search, search city 10km wide 10 km in length - 3km radius not reach city boundaries.

any ideas on query avoid this, or method list?

google's documentation not treat problem. however, find way using google maps api , geonames api. unfortunately, may have account in geonames api , google maps api.

you can consult this answer in stack overflow, download complete dump of geonames or consult documentation.

this code job:

/* * cities based on city name , radius in km */  // geocode object array google maps geocoding api $geocodeobject = json_decode(file_get_contents('https://maps.googleapis.com/maps/api/geocode/json?address={city name},{country code}'), true);  // latitude , longitude geocode object $latitude = $geocodeobject['results'][0]['geometry']['location']['lat']; $longitude = $geocodeobject['results'][0]['geometry']['location']['lng'];  // set request options $responsestyle = 'short'; // length of response $citysize = 'cities15000'; // minimal number of citizens city must have $radius = 30; // radius in km $maxrows = 30; // maximum number of rows retrieve $username = '{your username}'; // username of geonames account  // nearby cities based on range array geonames api $nearbycities = json_decode(file_get_contents('http://api.geonames.org/findnearbyplacenamejson?lat='.$latitude.'&lng='.$longitude.'&style='.$responsestyle.'&cities='.$citysize.'&radius='.$radius.'&maxrows='.$maxrows.'&username='.$username, true));  // foreach nearby city city details foreach($nearbycities->geonames $citydetails) {     // per nearby city } 

note, this answer not resolve problem google maps api , node.js only. post can edited or can take part of in order add own answer.

this post use code witch given in other answer in stack overflow in address.

sphynx tech


Comments