2015-11-06 145 views
-2

我的團隊正在開發一個數據挖掘項目,該項目使用Web表單從用戶那裏獲得輸入信息,處理一堆數據並生成旨在幫助執法的預測。我們要繪製我們的預測結果出來的網頁上的格式如下: http://www.crimemapping.com/map.aspx?aid=c99b299c-bc94-459a-b0dd-b871278930c3如何在Google地圖上繪製地圖標記並在點擊其中一個時顯示詳細信息?

  • 目標1:使用的位置標記一個谷歌地圖上繪製座標。
  • 目標2:點擊地點標記 時,在地圖上顯示某些細節。目標3:。如果我說'15'點要顯示,那麼網頁默認情況下會顯示一個'放大到'這15點的地圖?也就是說,我們不希望整個國家/地區顯示分數明顯集中在某個城市。

我一直在尋找相當一段時間,什麼是最好的方式來做到這一點。我想用Python來做,但似乎JS是更好的方法。我看到一些關於KLM和GoogleEarth的帖子,但對我的目的來說這似乎不太合適。

你能否給我一些建議,最好的方法是什麼?

回答

1

sample is形式谷歌文檔,你可以看到標記並點擊它的信息窗口

<!DOCTYPE html> 
<html> 
    <head> 
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> 
    <meta charset="utf-8"> 
    <title>Info windows</title> 
    <style> 
     html, body { 
     height: 100%; 
     margin: 0; 
     padding: 0; 
     } 
     #map { 
     height: 100%; 
     } 
    </style> 
    </head> 
    <body> 
    <div id="map"></div> 
    <script> 

// This example displays a marker at the center of Australia. 
// When the user clicks the marker, an info window opens. 

function initMap() { 
    var uluru = {lat: -25.363, lng: 131.044}; 
    var map = new google.maps.Map(document.getElementById('map'), { 
    zoom: 4, 
    center: uluru 
    }); 

    var contentString = '<div id="content">'+ 
     '<div id="siteNotice">'+ 
     '</div>'+ 
     '<h1 id="firstHeading" class="firstHeading">Uluru</h1>'+ 
     '<div id="bodyContent">'+ 
     '<p><b>Uluru</b>, also referred to as <b>Ayers Rock</b>, is a large ' + 
     'sandstone rock formation in the southern part of the '+ 
     'Northern Territory, central Australia. It lies 335&#160;km (208&#160;mi) '+ 
     'south west of the nearest large town, Alice Springs; 450&#160;km '+ 
     '(280&#160;mi) by road. Kata Tjuta and Uluru are the two major '+ 
     'features of the Uluru - Kata Tjuta National Park. Uluru is '+ 
     'sacred to the Pitjantjatjara and Yankunytjatjara, the '+ 
     'Aboriginal people of the area. It has many springs, waterholes, '+ 
     'rock caves and ancient paintings. Uluru is listed as a World '+ 
     'Heritage Site.</p>'+ 
     '<p>Attribution: Uluru, <a href="https://en.wikipedia.org/w/index.php?title=Uluru&oldid=297882194">'+ 
     'https://en.wikipedia.org/w/index.php?title=Uluru</a> '+ 
     '(last visited June 22, 2009).</p>'+ 
     '</div>'+ 
     '</div>'; 

    var infowindow = new google.maps.InfoWindow({ 
    content: contentString 
    }); 

    var marker = new google.maps.Marker({ 
    position: uluru, 
    map: map, 
    title: 'Uluru (Ayers Rock)' 
    }); 
    marker.addListener('click', function() { 
    infowindow.open(map, marker); 
    }); 
} 

    </script> 
    <script async defer 
     src="https://maps.googleapis.com/maps/api/js?callback=initMap"></script> 
    </body> 
</html> 
+0

謝謝,我想,和它的作品在我的本地。我有一個問題:有沒有理由不默認打開'放大'視圖的岩石?它向我展示整個澳大利亞。如果我說'15'點要顯示,我如何調整腳本以顯示默認情況下放大到15點的地圖? – learnerX

+0

如果我理解正確,您需要diffrente縮放。嘗試將縮放比例從4更改爲18,創建地圖 – scaisEdge

+0

對於您在項目中的地圖,我認爲Google地圖apis是更好的解決方案,您也可以使用這種方式使用衛星地圖。 – scaisEdge

相關問題