下面我得到了google/api地址的long/lat。但经度和latitube变量我需要在哪里使用gmap。正在创建map_canvas。使用函数外部的变量
在下一个函数中如何使用这些变量? (其中长/纬度每写现在的数字)
的Jquery:
var geocoder = new google.maps.Geocoder();
var address = markerInformation = $('#googleMapLocation').val();
geocoder.geocode({ 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
latitude = results[0].geometry.location.lat();
longitude = results[0].geometry.location.lng();
}
});
markerInformation = $('#googleMapInformation').val();
$(function() {
demo.add(function() {
$('#map_canvas').gmap({'center': '57.7973333,12.0502107', 'zoom': 10, 'disableDefaultUI':true, 'callback': function() {
var self = this;
self.addMarker({'position': this.get('map').getCenter() }).click(function() {
self.openInfoWindow({ 'content': markerInformation }, this);
});
}});
}).load();
});
感谢,做工精细!除了它不在该位置?我在西非得到中心 – Kim 2013-05-13 07:52:07
也许需要切换?位置:经度+','+纬度 – 2013-05-13 15:28:38
可能吧!但是它实际上把标记放在正确位置的地图上,但是它没有集中在位置 – Kim 2013-05-13 17:19:15