下面我得到了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