Google Web Map example-add multiple map annotations

Source: Internet
Author: User
Tags php tutorial

Google Web Map example-add multiple map annotations
<script src= "PS Tutorial. google.com/maps?file=api&amp;v=2&amp;key=abqiaaaac8kc8qqriigpsk23kp5gkbsh2hu1_ Yr14uohynbnrsdsru1coxqaa7zqsv6wfxh6g3z1aadux7pesa ">http://maps.google.com/maps?file=api&amp;v=2&amp ; Key=abqiaaaac8kc8qqriigpsk23kp5gkbsh2hu1_yr14uohynbnrsdsru1coxqaa7zqsv6wfxh6g3z1aadux7pesa "Type=" text/ JavaScript tutorial "charset=" Utf-8 ></script>n<body>
<div id= "Map" style= "width:800px; height:500px "></div><noscript><b>javascript must is enabled in the order of" for your use Google maps.< /b>
However, it seems JavaScript is either disabled or not supported by your browser.
To view Google Maps, enable JavaScript by changing your browser options, and then
Try again.
</noscript>
<script type= "Text/javascript" >
<! [cdata[

if (gbrowseriscompatible ()) {

Geocoder = new Gclientgeocoder ();

function Createmarker (point,html) {
var marker = new Gmarker (point);
Gevent.addlistener (Marker, "click", Function () {
marker.openinfowindowhtml (HTML);
});
return marker;
}

Display the map, with some controls and set the initial location
var map = new GMap2 (document.getElementById ("map"));
Map.addcontrol (New Gmaptypecontrol ());
Map.addcontrol (New Gsmallmapcontrol ());
Map.addcontrol (New Goverviewmapcontrol ());
Map.setcenter (New Glatlng ( -33.862828,151.216974), g_normal_map);

var point = new Glatlng ( -33.8619151,151.2091963);
var marker = Createmarker (point, ' Map.addoverlay (marker);

var point = new Glatlng ( -33.8683270,151.2086250);
var marker = Createmarker (point, ' Map.addoverlay (marker);

var point = new Glatlng ( -33.858362,151.214876);
var marker = Createmarker (point, ' Map.addoverlay (marker);

var point = new Glatlng ( -33.862828,151.216974);
var marker = Createmarker (point, ' Map.addoverlay (marker);


GMap.prototype.centerAndZoomOnBounds = function (bounds) {
Make 10% bigger so all markers show completely
var span = new Gsize ((Bounds.maxx-bounds.minx) * 1.1, (Bounds.maxy-bounds.miny) *1.1);
var center = new Gpoint (Bounds.minx + SPAN.WIDTH/2., Bounds.miny + SPAN.HEIGHT/2.);

var newzoom = this.spec.getLowestZoomLevel (center, span, this.viewsize);
if (This.getzoomlevel ()!= newzoom) {
This.centerandzoom (center, Newzoom);
} else {
THIS.RECENTERORPANTOLATLNG (center);
}
}

Display a warning if the browser is not compatible
} else {
Alert ("Sorry, the Google Maps API is isn't compatible with this browser");
}

]]>
</script></body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.