Http://space.itpub.net/14734354/viewspace-374828
I played a game a few days ago.GoogleOfMap API, It feels pretty good, very simple. Anyone who has any programming experience can master its main functions within 10 minutes after reading the following tutorials. In addition, I also made a simple small example, if you are interested, please refer to the http://sunjian100.googlepages.com/map.html:]
Step 1:
Apply for a KeyID from the http://www.google.com/apis/maps/signup.html
Step 2:
Add a reference to the MapAPI function library between HTML <title> </title>,
<Script. src = "http://maps.google.com/maps? File = api & v = 2 & key =YourKeyID"Type =" text/javascript "> </script>
Step 3:
Add a DIV named map to any location between HTML <body> </body>,
<Div id = "map" style = "width: 700px; height: 560px" align = "center"> </div>
Step 4:
Add the GMap class instance to the DIV named map,
<Script. type = "text/javascript">
// Create an instance of the GMap class
Var map = new GMap (document. getElementById ("map "));
// Add a control bar
Map. addControl (new GSmallMapControl ());
// Set the display mode to satellite image
Map. setMapType (G_SATELLITE_TYPE );
// Set the longitude and latitude of the center (Shanghai) And zoom coefficient, and display
Map. centerAndZoom (new GPoint (121.4838, 31.2517), 4 );
</Script>
Step 5:
Add 10 randomly marked points,
Var bounds = map. getBoundsLatLng ();
Var width = bounds. maxX-bounds. minX;
Var height = bounds. maxY-bounds. minY;
For (var I = 0; I <10; I ++ ){
Var point = new GPoint (bounds. minX + width * Math. random (),
Bounds. minY + height * Math. random ());
Var marker = createMarker (point, I + 1 );
// Add a tag
Map. addOverlay (marker );
}
Step 6:
Add event response,
Function createMarker (point, number)
{
Var marker = new GMarker (point );
// Show this marker's index in the info window when it is clicked.
Var html = "Marker # <B>" + number + "</B> ";
GEvent. addListener (marker, 'click', function (){
Marker. openInfoWindowHtml (html );});
Return marker;
}