0

ゲーム用のカスタム Google マップを作成しています。すべて順調に進んでいますが、マップ上の現在の部分にリンクするオプションを追加するのに苦労しています。

例: http://www.gta4.net/map/?lat=-19.775390625&lng=-7.91015625&z=5

この関数は API に存在しますか、それともカスタム スクリプトですか? もしそうなら、どうすればこれを達成できますか?

4

1 に答える 1

0

この機能は API にはありませんが、簡単に追加できます (テストされていません)。

 // If there are any parameters at eh end of the URL, they will be in  location.search
 // looking something like  "?marker=3"

 // skip the first character, we are not interested in the "?"
 var query = location.search.substring(1);

 // split the rest at each "&" character to give a list of  "argname=value"  pairs
 var pairs = query.split("&");
 for (var i=0; i<pairs.length; i++) {
   // break each pair at the first "=" to obtain the argname and value
   var pos = pairs[i].indexOf("=");
   var argname = pairs[i].substring(0,pos).toLowerCase();
   var value = pairs[i].substring(pos+1).toLowerCase();

   // process each possible argname  -  use unescape() if theres any chance of spaces
   if (argname == "id") {id = unescape(value);}
   if (argname == "marker") {index = parseFloat(value);}
   if (argname == "lat") {lat = parseFloat(value);}
   if (argname == "lng") {lng = parseFloat(value);}
   if (argname == "zoom") {zoom = parseInt(value);}
   if (argname == "type") {
     // from the v3 documentation 8/24/2010
     // HYBRID This map type displays a transparent layer of major streets on satellite images. 
     // ROADMAP This map type displays a normal street map. 
     // SATELLITE This map type displays satellite images. 
     // TERRAIN This map type displays maps with physical features such as terrain and vegetation. 
     if (value == "m") {maptype = google.maps.MapTypeId.ROADMAP;}
     if (value == "k") {maptype = google.maps.MapTypeId.SATELLITE;}
     if (value == "h") {maptype = google.maps.MapTypeId.HYBRID;}
     if (value == "t") {maptype = google.maps.MapTypeId.TERRAIN;}

   }
 }

// create the map
  var myOptions = {
    zoom: zoom,
    center: new google.maps.LatLng(lat,lng),
    mapTypeId: maptype,
    mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
    navigationControl: true,
    mapTypeId: maptype
}
map = new google.maps.Map(document.getElementById("map_canvas"),
                                myOptions);

実際の例( Mike Williams の v2 チュートリアルのこのページの例から移植)

于 2013-03-19T17:00:26.793 に答える