這是我v2的代碼工作(標記沒有顯示)GMAP V2 - > V3(自定義標記沒有顯示+如何添加php的地址)
<body onload="load()">
<div id="map_canvas" style="width: 520px; height: 370px"></div>
<script type="text/javascript">
var userLocation = '<?php echo $address; ?>';
如果(GBrowserIsCompatible()){ VAR地理編碼器= new GClientGeocoder(); geocoder.getLocations(用戶位置,功能(位置){
如果(locations.Placemark) { 變種北= locations.Placemark [0] .ExtendedData.LatLonBox.north; 變種南= locations.Placemark [0]。 ExtendedData.LatLonBox.south; 變種東= locations.Placemark [0] .ExtendedData.LatLonBox.east; 變種西= locations.Placemark [0] .ExtendedData.LatLonBox.west;
var bounds = new GLatLngBounds(new GLatLng(south, west),
new GLatLng(north, east));
var map = new GMap2(document.getElementById("map_canvas"));
var Icon = new GIcon();
Icon.image = "images/422marker.png";
Icon.iconSize = new GSize(33, 50);
map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
map.addOverlay(new GMarker(bounds.getCenter()), Icon);
}
}); }
這裏是我的V3代碼(標記不顯示的問題不知道如何利用我們的PHP用戶位置的地址腳本)
<body onload="load()">
<div id="map_canvas" style="width: 520px; height: 370px"></div>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
var userLocation = '5th Avenue, New York';
var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': userLocation}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
// Geolocation was sucessfull
// Set Marker Icon
var icon = new google.maps.MarkerImage('images/422marker.png',
new google.maps.Size(33,50),
new google.maps.Point(0,0),
new google.maps.Point(0,32));
// Move map to position and set zoom
map.setCenter(results[0].geometry.location);
map.setZoom(11);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location,
title: userLocation
//icon: icon
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
所以我有這個問題是folows:
V2:
自定義標記沒有顯示,所以更新的地圖,以V3
V3:
自定義標記不顯示+不知道如何使用我們的PHP代碼中心從另一個腳本在我們的座標中的地圖,獲取的(在V2的工作)
任何幫助表示讚賞。