Google Maps Application Developing —— Location
2012-01-30 00:37
381 查看
// (function () {
var map;
window.onload = function () {
// Creating a map
var mapOptions = {
zoom: 15,
center: new google.maps.LatLng(39.9, 116.4),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'), mapOptions);
// Checking if geo positioning is available
if (geo_position_js.init()) {
// Creating a settings object
var settings = {
enableHighAccuracy: true
};
// Trying to determine the location of the user
geo_position_js.getCurrentPosition(setPosition, handleError, settings);
} else {
alert('目前设备不支持地理定位!');
}
};
function handleError(error) {
alert('Error = ' + error.message);
}
function setPosition(position) {
// Creating a LatLng from the position info
var latLng = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
map.setCenter(latLng);
// Adding a marker to the map
var marker = new google.maps.Marker({
position: latLng,
map: map
});
// Creating an InfoWindow
var infoWindow = new google.maps.InfoWindow({
content: '你在这里!'
});
// Adding the InfoWindow to the map
infoWindow.open(map, marker);
// Zooming in on the map
map.setZoom(15);
}
})();
// ]]>
var map;
window.onload = function () {
// Creating a map
var mapOptions = {
zoom: 15,
center: new google.maps.LatLng(39.9, 116.4),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map'), mapOptions);
// Checking if geo positioning is available
if (geo_position_js.init()) {
// Creating a settings object
var settings = {
enableHighAccuracy: true
};
// Trying to determine the location of the user
geo_position_js.getCurrentPosition(setPosition, handleError, settings);
} else {
alert('目前设备不支持地理定位!');
}
};
function handleError(error) {
alert('Error = ' + error.message);
}
function setPosition(position) {
// Creating a LatLng from the position info
var latLng = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
map.setCenter(latLng);
// Adding a marker to the map
var marker = new google.maps.Marker({
position: latLng,
map: map
});
// Creating an InfoWindow
var infoWindow = new google.maps.InfoWindow({
content: '你在这里!'
});
// Adding the InfoWindow to the map
infoWindow.open(map, marker);
// Zooming in on the map
map.setZoom(15);
}
})();
// ]]>
<script type="text/javascript"> (function () { var map; window.onload = function () { // Creating a map var mapOptions = { zoom: 15, center: new google.maps.LatLng(31.35, 3.51), mapTypeId: google.maps.MapTypeId.ROADMAP }; map = new google.maps.Map(document.getElementById('map'), mapOptions); // Checking if geo positioning is available if (geo_position_js.init()) { // Creating a settings object var settings = { enableHighAccuracy: true }; // Trying to determine the location of the user geo_position_js.getCurrentPosition(setPosition, handleError, settings); } else { alert('目前设备不支持地理定位!'); } }; function handleError(error) { alert('Error = ' + error.message); } function setPosition(position) { // Creating a LatLng from the position info var latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude); // Adding a marker to the map var marker = new google.maps.Marker({ position: latLng, map: map }); // Creating an InfoWindow var infoWindow = new google.maps.InfoWindow({ content: '你在这里!' }); // Adding the InfoWindow to the map infoWindow.open(map, marker); // Zooming in on the map map.setZoom(15); } })(); </script>
相关文章推荐
- Google Maps Application Developing —— Quick Start
- Google Maps Application Developing —— Search Address
- GoogleMaps Location服务之Geocoder
- google maps navigation is not yet available in this location
- Location API and Google Maps in Android - Tutorial
- Google has disabled use of the Maps API for this application
- Google Maps API 2 文档
- Google Maps事件
- How to tell your iPhone application that location services are required | The Agile Warrior
- Location Services and Maps Programming Guide 纪录
- Android使用Google提供的地图实现定位时LocationListener的各个方法
- django-cron - A Django application that will run cron jobs for other django apps - Google Project Hosting
- 关于maps.google.com和ditu.google.cn地图偏差的说明
- Attempt to invoke virtual method 'com.google.android.gms.maps.GoogleMap com.google.android.gms.maps.
- Google Maps API Web Services文档使用
- Add Google Admob in Android Application
- Google Maps Control for ASP.Net - Part 2 (转载)
- Google Maps API 2 文档
- import com.google.android.maps missing
- Google Maps API指南:点击添加标注