var center_lat = 37.4419, center_lng = -122.1419, start_zoom = 13, map;
function to_zoom () {
map.zoomIn ();
map.zoomIn ();
map.zoomIn ();
}
function to_center () {
map.closeInfoWindow ();
map.setCenter ( new GLatLng (center_lat, center_long), start_zoom);
}
init()
map in which we initialize the map
variable as an object of the GMap2()
class GMap2()
, add controls to the map, set a marker on the map, and make it clickable. And here is the code:function init () {
if (GBrowserIsCompatible ()) {
map = new GMap2 ( document .getElementById ( "map" ));
map.addControl ( new GLargeMapControl ());
map.addControl ( new GMapTypeControl ());
map.setCenter ( new GLatLng (center_lat, center_long), start_zoom);
var latlng = new GLatLng (center_lat, center_long);
var marker = new GMarker (latlng, G_DEFAULT_ICON, {title: 'Marker' });
map.addOverlay (marker);
var html = "Some information will be located here." + "<br \/> <center> <a href=\"javascript:to_zoom();\"" Larger </a> | <a href== a> <\ / center> <br \ /> " ;
marker.openInfoWindowHtml (html);
}
}
window.onload = init;
window.onunload = GUnload;
Source: https://habr.com/ru/post/39435/
All Articles