English 中文(简体)
A. 谷歌地图中的大街
原标题:Highlight whole street in a Google Map with API

我有问题之分,说明如何把整个街道放在与APIC的角图上。 同我一样,我要就我网站上的地图上的具体道路提供一些数据,我如何能够使这条道路变成一个反映数据的具体颜色?

问题回答

基本办法是利用谷歌地图的标语绘制地图中两个任意街道点之间的路线。 这些要点必须与其LatLng坐标编码。 这里就是一个法典例子(如APICV2所示):

function initMap() {  // called by page onload event
  if (GBrowserIsCompatible()) {
    // set the initial location 
    gMap = new GMap2(document.getElementById("map_canvas"));
    gMap.addControl(new GLargeMapControl());
    gMap.setCenter(GLatLng(49.238326, 6.977761), 15);
// init directions object and attach listener to handle route loads from function     highliteRoute()
    gDir = new GDirections();
    gPoly = null;
    GEvent.addListener(gDir,  load , function(){
      gPoly = gDir.getPolyline();
      gMap.addOverlay(gPoly);

      // zoom & pan to poly        
      var polyBds  = gPoly.getBounds();
      var polyZoom = gMap.getBoundsZoomLevel(polyBds);
      gMap.setZoom(polyZoom);
      gMap.panTo(polyBds.getCenter());
    });
  }
}

function highliteRoute(){
  if(gPoly!=null)  gPoly.hide();
  gDir.load( from: 49.313530,6.969109 to: 49.238326,6.977761 , {getPolyline:true});
}




相关问题
How to decide the current point reach on google map?

How to decide the current point reach on google map? I have a list of points (pickup points) of a route that I want to show in my google map with polyline. Now i have to get the current location of ...

Topographical or relief data in Map APIs

I was wondering if anyone knew of any map APIs that offer topographical or relief data? I ve had a quick look at Google and Bing APIs, but could find nothing there. Google allow you to view a map as ...

Using maps on Windows Mobile

I m experimenting with maps on different mobile platforms. Getting Google Maps to work on Android was easy, following this tutorial. Getting the same to work on Windows Mobile is a different matter. ...

Adding a custom icon to a google map

I need a hand adding a custom icon to some Google Maps javascript. Code below for your reference: function populateMap() { var map = new GMap2(document.getElementById("map")); map.setCenter(new ...

RSS to KML Overlay

I m want to display my blog as a Google Map overlay (each post contains geotags). How can I dynamically create a KML overlay from an RSS? Or better, how can I create a loop (PHP) that would display ...

开放街道地图管理员

我需要开放Street的标记管理员。 地图,如山角地图。

热门标签