<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>画线</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
var poly;
var map;
var directionsDisplay;
var directionsService = new google.maps.DirectionsService();
var geocoder;
function initialize() {
geocoder = new google.maps.Geocoder();
var centerPoint = new google.maps.LatLng(23.0999442125314, 113.203125);
var myOptions = {
zoom: 4,
center: centerPoint,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById('map_canvas'), myOptions);
var polyOptions = {
strokeColor: 'red',
strokeOpacity: 1.0,
strokeWeight: 3
}
poly = new google.maps.Polyline(polyOptions);
poly.setMap(map);
directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.setMap(map);
var point = new google.maps.LatLng (37.37015718405753, 114.609375);
addLatLng(point,'A点','理','2011-11-21');
var point = new google.maps.LatLng (39.13006024213511, 115.48828125);
addLatLng(point,'B点','宁','2012-01-01');
var point = new google.maps.LatLng(23.241346102386135, 114.169921875);
addLatLng(point,'广州','xx','2012-01-16');
//calcRoute('37.37015718405753, 114.609375','39.13006024213511, 115.48828125');
//calcRoute('39.13006024213511, 115.48828125','23.241346102386135, 114.169921875');
}
</script>
<script type="text/javascript">
function addLatLng(point,mytitle,myname,time) {
var path = poly.getPath();
path.push(point);
var marker = new google.maps.Marker({
position: point,
title: mytitle,
map: map
});
//查询地址
// codeLatLng(point);
geocoder.geocode({'latLng': point}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
var con='姓名: '+myname +'<br> 时间: '+time+' <br>所在地:'+ results[1].formatted_address;
attachSecretMessage(marker,con);
}
} else {
alert("Geocoder failed due to: " + status);
}
});
}
function attachSecretMessage(marker,mycontent) {
var infowindow = new google.maps.InfoWindow(
{ content: mycontent,
size: new google.maps.Size(50,50)
});
google.maps.event.addListener(marker, 'click', function(response) {
infowindow.open(map,marker);
map.setCenter(marker.position);
map.setZoom(6);
});
}
//起点 终点
function calcRoute(start,end) {
var request = {
origin:start,
destination:end,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(result, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(result);
}
});
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas"></div>
</body>
</html>
分享到:
相关推荐
gmap.net实例,用C#语言开发的一个Demo
GMAP离线地图下载,支持谷歌、百度、高德、腾讯,支持行政区域与自定义下载,Zoom级别可以自定义设置,主要便于C#GMAP开发离线地图做参考,尤其是根据行政区域下载。
GMap.NET的两个核心库:GMap.NET.Core.dll以及GMap.NET.WindowsForms.dll
GMAP.net官方最新完整源代码,C#开源的地图组件可以进行Google、必应等地图的在线浏览及离线地图下载和浏览。
Gmap库,以及一个小型的示例demo
使用labview利用gmap.net加载电子地图
GMAP.net 默认高德地图
Gmap开源的强大的地图显示软件,不支持天地图资源,本资源研究天地图的切片方式,添加天地图的矢量和影像在线和离线显示。
wpf中关于Gmap.net地图的开发 里面有怎么添加自定义标注 有google bingmap
GMap 自定义Marker以及规则图形的绘制
C#调用GMap在地图上打点, 绘制多边形, 显示标签, 点闪烁
C# GMap.net高德地图的用法,经实验可行。 同时包含在线地图和离线地图的用法。
GMap.NET下载离线地图下载即用谷歌百度腾讯高德
C#/MP地面站运行报错:“System.Data”中不存在类型或命名空间名称...应该是GMap.NET.Core\bin\Debug缺少这个文件,本人是直接将Debug里面文件全部复制了进去(版本是Vs2017.net4)如果用不了可尝试自己执行编译。
C# Winform开发使用离线地图 GMap 基础例程,包括导入离线地图,地图图层绘制标点、多边形、圆、图片、鼠标移动显示坐标经纬度等。
C#Gmap加载高德地图项目,含覆盖物多边形等操作,自己可以参照该项目编写百度地图的Provider
GMap机制和重写 1.GMarker底层机制默认IsHitTestVisible=true,导致鼠标在Marker上的时候拖动不了地图图层和滚轮缩放地图。个人之前开发惯B端地图项目,觉得这是一个很不好的体验。改改改,GMapControl改底层事件 2...
C# GMap.net百度地图的在线地图和离线地图的的用法。 经严格反复的实验,可行可用。