Вот мой код v2, который работает (маркер не показывает)
<body onload="load()">
<div id="map_canvas" style="width: 520px; height: 370px"></div>
<script type="text/javascript">
var userLocation = '<?php echo $address; ?>';
if (GBrowserIsCompatible ()) {
var geocoder = new GClientGeocoder ();
geocoder.getLocations (userLocation, функция (местоположения) {
if (location.Placemark)
{
var north = location.Placemark [0] .ExtendedData.LatLonBox.north;
var south = location.Placemark [0] .ExtendedData.LatLonBox.south;
var east = location.Placemark [0] .ExtendedData.LatLonBox.east;
var west = location.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 userLocation)
<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);
}
});
Итак, у меня проблема в следующем:
v2:
Пользовательский маркер не отображается, поэтому обновлена карта до v3
v3:
Пользовательский маркер не показывает + не уверен, как использовать наш php-код для центрирования карты на наших координатах, полученных из другого скрипта (который работал в v2)
Любая помощь приветствуется.