add Map Zoom to this code ( gmap )
We use this script to show Gmap, but I cannot for the life of me remember who did it for us, what I do know is we need a Map Zoom added to it.. buggered if I know how.
The script is as follows:
var userLocation = '<?php echo $address; ?>';
if (GBrowserIsCompatible())
{
var geocoder = new GClientGeocoder();
geocoder.getLocations(userLocation, function (locations)
{
if (locations.Placemark)
{
var north = locations.Placemark[0].ExtendedData.L开发者_如何学CatLonBox.north;
var south = locations.Placemark[0].ExtendedData.LatLonBox.south;
var east = locations.Placemark[0].ExtendedData.LatLonBox.east;
var west = 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 = "http://somesite.com/marker.png";
Icon.iconSize = new GSize(33, 50);
map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds));
map.addOverlay(new GMarker(bounds.getCenter()), Icon);
}
});
}
The PHP actually grabs address from our dB and the map plots that location, which shouldn't have anything to do with the script.
Just need the zoom feature.
I have tried adding:
mapTypeControl: false,
zoomControl: true,
With no luck... I am a total gMap noob.
This looks like Google Maps API version 2 code. Documentation can be found here.
var map = new GMap2(document.getElementById("map_canvas"));
// //// add this code \\\\
map.addControl(new GLargeMapControl3D()); // large pan+zoom control (3d)
// \\\\ add this code ////
var Icon = new GIcon();
You can use (and add) other controls as well. For example:
GSmallMapControl
-- compact version of pan+zoom controlGSmallZoomControl
-- compact version of zoom controlGScaleControl
-- adds scale information to the mapGMapTypeControl
-- map type chooser control (toggle b/w map, satellite, hybrid etc)
精彩评论