简体   繁体   English

从数据库中的城市创建Google Maps标记

[英]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 . 我目前正在尝试构建自己的Google地图,以显示学生所在的每个位置,类似于这样的位置 I've looked into Zeemaps, but it seems to only accept imports from a CSV file. 我研究了Zeemaps,但它似乎只接受来自CSV文件的导入。

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. 我的第一个问题是是否可以仅使用城市,州和国家/地区创建标记(我不能为国际学生使用Zip,出于隐私原因我想避免使用特定地址),而是比经纬仪要长。 I see this example for creating the marker from W3schools 我看到了这个从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? 如果不是,那么Google Maps API中是否有任何其他函数可以转换其他函数?

You are looking for Geocoding it is also from Google Maps API. 您正在从Google Maps API寻找地理编码。 I know that each city has a geolocation. 我知道每个城市都有地理位置。 and you can query for the LatLng coordinates. 您可以查询LatLng坐标。 When you query by addressName just leave out the zip it will give you the coordinates closest. 当您通过addressName查询时,只需省略邮政编码,它就会为您提供最接近的坐标。 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 也许它将为您指明正确的方向

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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