简体   繁体   中英

Creating Google Maps markers from cities in a database

I'm currently trying to build my own Google Map that will display each of the locations of where students are from, similar to one like this . I've looked into Zeemaps, but it seems to only accept imports from a CSV file.

My first question would be whether it is possible to create a marker with just the City, State and Country (I wouldn't be able to use Zip for international students, and I want to avoid having a specific address for privacy reasons), rather than the Lat and Long. I see this example for creating the marker from W3schools

var myCenter=new google.maps.LatLng(51.508742,-0.120850);

var marker=new google.maps.Marker({
  position:myCenter,
});

Is there a similar way to create a point with City, [State], Country?

And if not, are there any in-between functions from the Google Maps API that could do the conversions in another function?

You are looking for Geocoding it is also from Google Maps API. I know that each city has a geolocation. and you can query for the LatLng coordinates. When you query by addressName just leave out the zip it will give you the coordinates closest. Coordinates for a city may sometimes go to its central station or wherever that maybe a geographical center of that particular city.

Read Here . maybe it will point you in the right direction

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM