Google API v2转换为Google Map v3 [英] Google api v2 to convert in to Google map v3

查看:107
本文介绍了Google API v2转换为Google Map v3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的网站使用google api v2运行.现在我想转换为google map v3.如何在以下代码中进行更改.最近我收到一条消息,提示v2已禁用.因此,我想使用当前功能.

================================================== ================

My site running with google api v2.Now I wants to convert in to google map v3.How can make changes in the following code.Recently I had got a message that v2 is disabled.So I wants to modify existing script with current functions.

==================================================================

var maprecent;
function init_maprecent() {
function createMarker(point, myHtml) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { maprecent.openInfoWindowHtml(point, myHtml, {maxWidth:200}); }); return marker; }
var markerindex = 0; var markers = new Array();
function animate_marker() {if (markerindex==markers.length) {markerindex=0;} GEvent.trigger(markers[markerindex], "click"); markerindex++; setTimeout(animate_marker, 5000);}
var bottomLeft = new GControlPosition(G_ANCHOR_BOTTOM_LEFT);
maprecent = new google.maps.Map(document.getElementById("smallmaprecent"));
maprecent.addControl(new GSmallZoomControl());
maprecent.addControl(new GMapTypeControl(), bottomLeft);
maprecent.setCenter(new GLatLng(34.051072,-118.259961), 5);


var m0 = createMarker(new GLatLng(34.016919,-118.5010608), 'test<br>demo<br><a href="http://www.abcd.com/project_47_test.html">View project</a><br>London   ');
maprecent.addOverlay(m0);
markers.push(m0);
maprecent.addOverlay(new GPolygon([new GLatLng(34.016919,-118.5010608), new GLatLng(34.016919,-118.5010608), new GLatLng(34.016919,-118.5010608), new GLatLng(34.016919,-118.5010608), new GLatLng(34.016919,-118.5010608)], "#000000", 1, 0.5, "#444488", 0.1));
animate_marker();
}


================================================== ===================


======================================================================

    include ("includes/config.php");
$z=0;
$fcontent='

var maprecent;
function init_maprecent() {
function createMarker(point, myHtml) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { maprecent.openInfoWindowHtml(point, myHtml, {maxWidth:200}); }); return marker; }
var markerindex = 0; var markers = new Array();
function animate_marker() {if (markerindex==markers.length) {markerindex=0;} GEvent.trigger(markers[markerindex], "click"); markerindex++; setTimeout(animate_marker, 5000);}
var bottomLeft = new GControlPosition(G_ANCHOR_BOTTOM_LEFT);
maprecent = new GMap2(document.getElementById("smallmaprecent"));
maprecent.addControl(new GSmallZoomControl());
maprecent.addControl(new GMapTypeControl(), bottomLeft);
maprecent.setCenter(new GLatLng(34.051072,-118.259961), 5);
';



$db = mysql_connect($config['DB_Host'], $config['DB_User'],$config['DB_Passwd']);
mysql_select_db($config['DB_Name'],$db);
$result = mysql_query("SELECT * from project_master  WHERE location != '' ORDER BY project_id",$db);
while ($myrow = mysql_fetch_row($result)) {
    $ce=$myrow[6];
    $linkid=$myrow[0];
    $link1=str_replace(" ","-",$ce);
    $link2=strtolower($link1);
$zipcode="$myrow[29]";

     $cine=$myrow[1];
     $result2 = mysql_query("SELECT mem_address,mem_zip_code from member_master WHERE user_login_id='$cine' LIMIT 1",$db);
while ($myrow2 = mysql_fetch_row($result2)) {
     //$zipcode="$myrow2[0]";
}


   $result2 = '';

for ($i=0; $i<strlen($link2);>if (preg_match('([0-9]|[a-z]|_|-)', $link2[$i])) {
$result2 = $result2 . $link2[$i];
}
}
$finallink=$result2;
$mainlink="http://abcd.com/project_".$linkid."_".$finallink.".html";

$cine=$myrow[1];
//print "$cine $zipcode $ce $mainlink<br>";

//print "Zipcode $zipcode";


$longitude = "";
$latitude = "";
$precision = "";

//Three parts to the querystring: q is address, output is the format (
$key = "";
$address = urlencode("$zipcode");
$url = "http://maps.google.com/maps/geo?q=".$address."&output=json&key=".$key;

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$data = curl_exec($ch);
curl_close($ch);

$geo_json = json_decode($data, true);

//print_r($geo_json);

if ($geo_json['Status']['code'] == '200') {

$precision = $geo_json['Placemark'][0]['AddressDetails']['Accuracy'];
$latitude = $geo_json['Placemark'][0]['Point']['coordinates'][0];
$longitude = $geo_json['Placemark'][0]['Point']['coordinates'][1];

//echo "Precision: $precision \n";
//echo "Latutide: $latitude \n";
//echo "Longitude: $longitude \n";

} else {
//echo "Error in geocoding! Http error ".substr($data,0,3);
}


$zipcode=stripslashes($zipcode);
$zipcode=substr($zipcode,0,30);

if ($longitude!="")
{

$fcontent.= "

var m$z = createMarker(new GLatLng($longitude,$latitude), '$ce<br>$cine<br><a href="$mainlink">View project</a><br>$zipcode  ');
maprecent.addOverlay(m$z);
markers.push(m$z);
maprecent.addOverlay(new GPolygon([new GLatLng($longitude,$latitude), new GLatLng($longitude,$latitude), new GLatLng($longitude,$latitude), new GLatLng($longitude,$latitude), new GLatLng($longitude,$latitude)], \"#000000\", 1, 0.5, \"#444488\", 0.1));
";
$z++;
}

}



$fcontent.="animate_marker();
}";
//print $fcontent;
$fcontent=trim($fcontent);
$myFile = "recent.js";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $fcontent);
fclose($fh);

?>

推荐答案

z = 0;


fcontent = ' var maprecent; 函数init_maprecent(){ 函数createMarker(point,myHtml){var marker = new GMarker(point); GEvent.addListener(marker,"click",function(){maprecent.openInfoWindowHtml(point,myHtml,{maxWidth:200});});返回标记; } var markerindex = 0; var markers = new Array(); 函数animate_marker(){if(markerindex == markers.length){markerindex = 0;} GEvent.trigger(markers [markerindex],"click"); markerindex ++; setTimeout(animate_marker,5000);} var bottomLeft =新的GControlPosition(G_ANCHOR_BOTTOM_LEFT); maprecent =新的GMap2(document.getElementById("smallmaprecent")); maprecent.addControl(new GSmallZoomControl()); maprecent.addControl(new GMapTypeControl(),bottomLeft); maprecent.setCenter(new GLatLng(34.051072,-118.259961),5); ';
fcontent=' var maprecent; function init_maprecent() { function createMarker(point, myHtml) { var marker = new GMarker(point); GEvent.addListener(marker, "click", function() { maprecent.openInfoWindowHtml(point, myHtml, {maxWidth:200}); }); return marker; } var markerindex = 0; var markers = new Array(); function animate_marker() {if (markerindex==markers.length) {markerindex=0;} GEvent.trigger(markers[markerindex], "click"); markerindex++; setTimeout(animate_marker, 5000);} var bottomLeft = new GControlPosition(G_ANCHOR_BOTTOM_LEFT); maprecent = new GMap2(document.getElementById("smallmaprecent")); maprecent.addControl(new GSmallZoomControl()); maprecent.addControl(new GMapTypeControl(), bottomLeft); maprecent.setCenter(new GLatLng(34.051072,-118.259961), 5); ';


db = mysql_connect(
db = mysql_connect(


这篇关于Google API v2转换为Google Map v3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆