【发布时间】:2012-02-18 05:56:21
【问题描述】:
代码运行良好,但我想添加自己的位置。 例如在下面的脚本中
map.setCenter(新 google.maps.LatLng(37.4419, -122.1419), 13);
如果我想要印度浦那地图,我会给我那个特定位置的地图 那么我需要把这个位置放在哪里,或者我怎样才能得到这个位置的纬度 lng?
我该怎么做请帮助我,我是 mvc 的新手。
<script type="text/javascript" src="http://www.google.com/jsapi?key=mykey"></script>
<script type="text/javascript">
var allMarks = [];
google.load("maps", "2");
//This function will help us to add the mark at
//location where user has double clicked. Then
//we will add all the marks in our array so that
//we can send it back to the controller
function initialize() {
var map = new google.maps.Map2(document.getElementById("map"));
map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);
marker = new google.maps.marker
map.setUIToDefault();
GEvent.addListener(map, "dblclick", function(overlay, latlng) {
if (latlng) {
var mark = new GMarker(latlng);
allMarks.push(latlng);
map.addOverlay(mark);
}
});
}
google.setOnLoadCallback(initialize);
//This function will be called for saving the mark
//for that it will send the data back to the controller
function saveMap() {
//gmap object with all values of the map mark
var gmap = {
Locations: allMarks,
Description: Description.value
}
//Ajax call for saving the data at the server. It will send the gmap
//object tot the server
$.ajax({
type: "POST",
url: "/Home/Create",
data: gmap
});
}
</script>
【问题讨论】:
-
“添加我自己的位置”是什么意思?添加标记?将地图居中?为了提供帮助,我们需要更多关于您想要完成的工作的信息。
-
我的意思是在上面的脚本中 map.setCenter(new google.maps.LatLng(37.4419, -122.1419), 13);如果我想显示印度浦那位置的地图,那么我需要在脚本中添加此位置的位置。?
标签: javascript asp.net-mvc google-maps google-maps-api-3