PHP calls Google API map display code

Source: Internet
Author: User

PHP calls Google API map display code
Google.load ("Maps", "2.x");
Google.setonloadcallback (initialize);

var map = null;
var geocoder = null;
function Initialize () {
Detect if IE supports Google Map API
if (gbrowseriscompatible ()) {
Map = new Google.maps.Map2 (document.getElementById (' map '));
Geocoder = new Gclientgeocoder ();

Set up a map center
Map.setcenter (New Glatlng (25.036772,121.520269), 12);
}//If
else {
Alert (' Your traffic does not support Google Map ');
}//Else
}

function Showlocation () {
Clear Marker
Map.clearoverlays ();
var address = document.getElementById (' txtaddress '). Value;
Geocoder.getlocations (address, cb_showlocation);
}

function Cb_showlocation (Result) {
Show results
if (result. Status.code = = g_geo_success) {
Success
for (var i=0; I<result. Placemark.length; i++) {
var lat = result. Placemark[i]. POINT.COORDINATES[1];

Lat
var LNG = result. Placemark[i]. Point.coordinates[0];

Lng
var address = result. placemark[i].address; Address
var point = new Glatlng (LAT,LNG);

var marker=new gmarker (Point, {title:i+1});;
Map.addoverlay (marker);
}//For
}//If
}

Var status=[];
status[g_geo_success]            = "SUCCESS";
status[g_geo_missing_address]    = "MISSING address";
status[g_geo_unknown_address]    = "UNKNOWN address";
status[g_geo_unavailable_address]= "unavailable address";
status[g_geo_bad_key]            = "Bad KEY";
status[g_geo_too_many_queries]   = "TOO MANY QUERIES";
status[g_geo_server_error]       = "SERVER ERROR";

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.