【发布时间】:2012-02-15 18:20:13
【问题描述】:
我有以下 Javascript 代码,我想为我的地图应用反向地理编码
这是我的 JS 代码
更新
<script type="text/javascript">
var map;
var geocoder;
var markers = new Array();
function initialize() {
geocoder = new google.maps.Geocoder();
var GPS = <%=GPS %>
var latlng = new google.maps.LatLng(31.2330555556,72.3330555556);
var myOptions = {
zoom: 7,
scaleControl:true,
pancontrol: true,
streetViewControl: true,
center: latlng,
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
mapTypeId: google.maps.MapTypeId.HYBRID
}
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var infowindow = new google.maps.InfoWindow();
for(i=0; i<GPS.length; i++)
{
//GeoCoding
if (geocoder) {
geocoder.geocode({'latLng': latlng}, function(results, status)
{
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
markers[i] = new google.maps.Marker(
{
position: GPS[i].GPS,
map: map,
draggable:true,
Info: results[1].formatted_address,
title:GPS[i].TITLE
}
}
}
});
google.maps.event.addListener(markers[i], 'click', function() {
infowindow.setContent(this.Info);
infowindow.open(map,this);
});
}
}
</script>
先生,这是我的更新代码,我在其中编写了反向地理编码的代码,但现在 MU 地图不工作请告诉我我到底错过了什么
【问题讨论】:
-
如果它在实时站点上,或者如果您将完整代码放入 jsFiddle 之类的东西中以便我们进行测试,则更容易调试。
-
同意 Mano,您确实需要链接到实时代码。
标签: javascript google-maps-api-3 reverse-geocoding