Bing 地图上的多边形使用本地 GeoJSON 对象导致位置错误
Polygon on Bing Map using Local GeoJSON Object results in wrong location
我正在使用 Bing Map v8 在地图上绘制多边形。
出于某种原因,即使我使用相同的坐标,两种不同的方法也会导致不同的结果。
这个方法
如图所示here
效果很好:
map = new Microsoft.Maps.Map(document.getElementById("map"), {
credentials: '',
mapTypeId: Microsoft.Maps.MapTypeId.aerial,
});
var polygon = new Microsoft.Maps.Polygon([
new Microsoft.Maps.Location(32.57922,34.91395),
new Microsoft.Maps.Location(32.53799,34.9021),
new Microsoft.Maps.Location(32.53264,34.91292),
new Microsoft.Maps.Location(32.55398,34.92339),
new Microsoft.Maps.Location(32.57156,34.93489),
new Microsoft.Maps.Location(32.57503,34.92614)],
{ fillColor: 'rgba(241, 227, 100, 0.3)', strokeColor: 'rgba(241, 227, 100, 0.8)', strokeThickness: 1 });
map.entities.push(polygon);
当使用如图所示的Microsoft.Maps.GeoJson.read方法here读取具有相同多边形坐标的 GeoJson 对象时,多边形绘制在距原始位置西北数百英里的区域中.这是为什么?
map = new Microsoft.Maps.Map(document.getElementById("map"), {
credentials: '',
mapTypeId: Microsoft.Maps.MapTypeId.aerial,
});
//define polygon using GeoJson Object
var GeoJson = {
"type": "Polygon",
"coordinates": [[
[32.57922,34.91395],
[32.53799,34.9021],
[32.53264,34.91292],
[32.55398,34.92339],
[32.57156,34.93489],
[32.57503,34.92614]
]]
};
//Load the GeoJson Module.
Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', function () {
//Parse the GeoJson object into a Bing Maps shape.
var shape = Microsoft.Maps.GeoJson.read(GeoJson, {
polygonOptions: {
fillColor: 'rgba(255,0,0,0.5)',
strokeColor: 'rgba(241, 227, 100, 0.8)',
strokeThickness: 1
}
});
//Add the shape to the map.
//results in wrong location !
map.entities.push(shapeA);
});
Bing 地图位置采用纬度、经度,而 GeoJSON positions/coordinates 是 longitude/latitude。反转 GeoJSON 坐标中的数字。
我正在使用 Bing Map v8 在地图上绘制多边形。 出于某种原因,即使我使用相同的坐标,两种不同的方法也会导致不同的结果。
这个方法 如图所示here 效果很好:
map = new Microsoft.Maps.Map(document.getElementById("map"), {
credentials: '',
mapTypeId: Microsoft.Maps.MapTypeId.aerial,
});
var polygon = new Microsoft.Maps.Polygon([
new Microsoft.Maps.Location(32.57922,34.91395),
new Microsoft.Maps.Location(32.53799,34.9021),
new Microsoft.Maps.Location(32.53264,34.91292),
new Microsoft.Maps.Location(32.55398,34.92339),
new Microsoft.Maps.Location(32.57156,34.93489),
new Microsoft.Maps.Location(32.57503,34.92614)],
{ fillColor: 'rgba(241, 227, 100, 0.3)', strokeColor: 'rgba(241, 227, 100, 0.8)', strokeThickness: 1 });
map.entities.push(polygon);
当使用如图所示的Microsoft.Maps.GeoJson.read方法here读取具有相同多边形坐标的 GeoJson 对象时,多边形绘制在距原始位置西北数百英里的区域中.这是为什么?
map = new Microsoft.Maps.Map(document.getElementById("map"), {
credentials: '',
mapTypeId: Microsoft.Maps.MapTypeId.aerial,
});
//define polygon using GeoJson Object
var GeoJson = {
"type": "Polygon",
"coordinates": [[
[32.57922,34.91395],
[32.53799,34.9021],
[32.53264,34.91292],
[32.55398,34.92339],
[32.57156,34.93489],
[32.57503,34.92614]
]]
};
//Load the GeoJson Module.
Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', function () {
//Parse the GeoJson object into a Bing Maps shape.
var shape = Microsoft.Maps.GeoJson.read(GeoJson, {
polygonOptions: {
fillColor: 'rgba(255,0,0,0.5)',
strokeColor: 'rgba(241, 227, 100, 0.8)',
strokeThickness: 1
}
});
//Add the shape to the map.
//results in wrong location !
map.entities.push(shapeA);
});
Bing 地图位置采用纬度、经度,而 GeoJSON positions/coordinates 是 longitude/latitude。反转 GeoJSON 坐标中的数字。