简体   繁体   English

多边形未显示在gmap上

[英]Polygons are not shown on gmap

We have a problem creating polygons, as they do not appear on the map. 我们在创建多边形时遇到问题,因为它们没有出现在地图上。 We have followed this tutorial to implement our solution: http://googlemaps.subgurim.net/ejemplos/ejemplo_94100_Pol%C3%ADgonos.aspx 我们已按照本教程实施我们的解决方案: http//googlemaps.subgurim.net/ejemplos/ejemplo_94100_Pol%C3%ADgonos.aspx

The application is developed in visual basic. 该应用程序是在visual basic中开发的。 Net framework version 4. 网络框架版本4。

This is part of our code where we are generating the polygon on the map. 这是我们在地图上生成多边形的代码的一部分。

Dim latlng As New GLatLng(46, 21)
GMap1.setCenter(latlng, 4)

Dim puntos As New List(Of GLatLng)()
puntos.Add(latlng + New GLatLng(0, 8))
puntos.Add(latlng + New GLatLng(-0.5, 4.2))
puntos.Add(latlng)
puntos.Add(latlng + New GLatLng(3.5, -4))
puntos.Add(latlng + New GLatLng(4.79, +2.6))

Dim poligono As New GPolygon(puntos, "557799", 3, 0.5, "237464", 0.5)
poligono.close()

GMap1.Add(poligono)

We thank who can provide help to solve this problem we have. 我们感谢谁能提供帮助来解决我们遇到的这个问题。

Attachment I leave a map image, which if located according to the coordinates given but considering that the polygon is not displayed. 附件我留下地图图像,如果根据给定的坐标定位但考虑到不显示多边形。

It has something today with the Javascript array definition. 今天它有Javascript数组定义。

When you call GMap1.Add() you will notice that the polygon.ToString() causes a [[ in the resulting Javascript. 当您调用GMap1.Add()时,您会注意到polygon.ToString()导致[[在生成的Javascript中。

Replacing the [[ with a [ will solve your issue. 替换[[with a [将解决您的问题。

If you are using the Add overload accepting a polygon you will need to change your code a bit, to make use of the custom Javascript overload. 如果您使用Add overload接受多边形,则需要稍微更改一下代码,以利用自定义Javascript重载。

To reproduce the first polygon example located on their website at http://en.googlemaps.subgurim.net/ejemplos/ejemplo_94100_Pol%C3%ADgonos.aspx something along the following lines will do: 要重现位于其网站http://en.googlemaps.subgurim.net/ejemplos/ejemplo_94100_Pol%C3%ADgonos.aspx上的第一个多边形示例,请执行以下操作:

GLatLng latlng = new GLatLng( 46, 21 );
GMap1.setCenter( latlng, 4 );
List<GLatLng> puntos = new List<GLatLng>();
puntos.Add( latlng + new GLatLng( 0, 8 ) );
puntos.Add( latlng + new GLatLng( -0.5, 4.2 ) );
puntos.Add( latlng );
puntos.Add( latlng + new GLatLng( 3.5, -4 ) );
puntos.Add( latlng + new GLatLng( 4.79, +2.6 ) );
GPolygon poligono = new GPolygon( puntos, "557799", 3, 0.5, "237464", 0.5 );
poligono.close();

var objJs = new StringBuilder();
objJs.Append("function addborder" + 0 + "()");
objJs.Append("{");
objJs.Append( poligono.ToString( GMap1.GMap_Id ) );
objJs.Replace("clickable:False", "clickable:false");//  ' Replace incorrect False statement
objJs.Append("}");

GMap1.Add( "addborder" + 0 + "();", true );
var objString = objJs.ToString();
var newstring = objString.Replace( "[[", "[" ).Replace( "]]", "]" );
GMap1.Add( newstring );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM