English 中文(简体)
如何在谷歌地图中显示静态图像?
原标题:How to show a static image in google maps?

基本上,我想在我的地图中间展示一个十字路口, 留在中间,当用户盘旋时。

我正是在谈论这个, 除了这个例子执行不力,

http://www.daftlogic.com/sandbox-google-maps-centre-crosshairs.htm

有没有人想过用V3地图Api来实施这个计划?

最佳回答

我所看到的最平滑的方法是使用 KML 文件 。 < a href="http://maps.google.com/maps? f=q&hl=en&q=http://kmlcriple.googlepages.com/SamplesInMaps.kml&ie=UTF8&ll=36.879621,-534375&spn=103.772916. 208.476563&z=2&om=1, rel="nofollow"。 这是原始的 。

我将KML剥除到最起码的限度:

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
  <Document>
      <ScreenOverlay>
        <Icon>
          <href>http://code.google.com/apis/kml/documentation/crosshairs.png</href>
        </Icon>
        <overlayXY x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
        <screenXY x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
        <rotationXY x="0.5" y="0.5" xunits="fraction" yunits="fraction"/>
        <size x="0" y="0" xunits="pixels" yunits="pixels"/>
      </ScreenOverlay>
  </Document>
</kml>

在地图代码中,您需要做的只是设置 KML 图层, 选项为 < code> preserverveViport= true 。 请注意, 如果您在本地重新测试 KML 文件, 仍然需要上传到公共位置 。

  var crosshairLayer = new google.maps.KmlLayer( 
       http://freezoo.alwaysdata.net/justcrosshair2.kml , 
      {preserveViewport: true});

    crosshairLayer.setMap(map);

JSFiddle style 1 style 2

(在两个 KML 文件中,它们重新代表两个独立的图标 。)

问题回答

暂无回答




相关问题
Why do I get "map.set_center is not a function"?

This code have been working until I updated last night. The code works perfectly on my localhost, but I get an error on my test server. The error message (from Firebug) is "map.set_center is not a ...

The state of GMaps v3

I m about to start a Google map based project and am wondering if the release version of GMaps v3 has most of the features that are available in v2, or if it would be best to stick with v2 for now. Is ...

Bouncy marker in Google Maps v3

In Google Maps API v2 we can set to marker an option bouncy:true. It adds to marker eye-candy ability - after dragging this marker, it is bouncing. Is it possible to do in API v3 ?

GUnload() a single Google Map

I ve got some Javascript/HTML code which displays a variable number of maps dependent on what the user selects. I ve worked how to dynamically create multiple maps on a page - that s well documented. ...

How to change Gmap markers color?

I ve a custom google map with different points: Markers[0] = new Array(new GMarker(new GLatLng(45.0, 9.0)), "Location1", "<strong>Address Line</strong><br/>Some information"); ...

热门标签