3

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

The application is developed in visual basic. Net framework version 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.

Andrea Scarcella
  • 3,233
  • 2
  • 22
  • 26
araad1992
  • 104
  • 10
  • I answered the question at: http://stackoverflow.com/questions/22346498/google-maps-subgurim-polygons-are-not-working-anymore/23081556#23081556 – AGhosT Apr 15 '14 at 10:56

1 Answers1

1

It has something today with the Javascript array definition.

When you call GMap1.Add() you will notice that the polygon.ToString() causes a [[ in the resulting Javascript.

Replacing the [[ with a [ will solve your issue.

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.

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:

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 );
AGhosT
  • 113
  • 1
  • 11