I want to display Google map in my web page based on longitude and latitude. First user want to enter longitude and latitude in two text box's. Then click submit button I have to display appropriate location in Google map.And also I want to show the weather report on it.How to do that? Thank You.
我想根据经度和纬度在我的网页上显示谷歌地图。第一个用户想要在两个文本框中输入经度和纬度。然后点击提交按钮我必须在谷歌地图中显示适当的位置。而且我还要在其上显示天气报告。怎么做?谢谢。
3 个解决方案
#1
92
Create a URI like this one:
创建一个像这样的URI:
http://maps.google.com/?q=[lat],[long]
http://maps.google.com/?q=[lat],[long]
For example:
例如:
http://maps.google.com/?q=-37.866963,144.980615
http://maps.google.com/?q=-37.866963,144.980615
or, if you are using the javascript API
或者,如果您使用的是JavaScript API
map.setCenter(new GLatLng(0,0))
This, and other helpful info comes from here:
这个和其他有用的信息来自这里:
http://code.google.com/apis/maps/documentation/javascript/reference.html#Map
http://code.google.com/apis/maps/documentation/javascript/reference.html#Map
#2
19
this is the javascript to display google map by passing your longitude and latitude.
这是通过传递经度和纬度来显示谷歌地图的JavaScript。
<script>
function initialize() {
var myLatlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
#3
3
Have you gone through google's geocoding api. The following link shall help you get started: http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests
你有没有通过谷歌的地理编码api。以下链接可帮助您入门:http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests
#1
92
Create a URI like this one:
创建一个像这样的URI:
http://maps.google.com/?q=[lat],[long]
http://maps.google.com/?q=[lat],[long]
For example:
例如:
http://maps.google.com/?q=-37.866963,144.980615
http://maps.google.com/?q=-37.866963,144.980615
or, if you are using the javascript API
或者,如果您使用的是JavaScript API
map.setCenter(new GLatLng(0,0))
This, and other helpful info comes from here:
这个和其他有用的信息来自这里:
http://code.google.com/apis/maps/documentation/javascript/reference.html#Map
http://code.google.com/apis/maps/documentation/javascript/reference.html#Map
#2
19
this is the javascript to display google map by passing your longitude and latitude.
这是通过传递经度和纬度来显示谷歌地图的JavaScript。
<script>
function initialize() {
var myLatlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 8,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
function loadScript() {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initialize";
document.body.appendChild(script);
}
window.onload = loadScript;
</script>
#3
3
Have you gone through google's geocoding api. The following link shall help you get started: http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests
你有没有通过谷歌的地理编码api。以下链接可帮助您入门:http://code.google.com/apis/maps/documentation/geocoding/#GeocodingRequests