Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps API v3 - GIcon is not defined

I know they are some issues from v2 to v3 what can i do here to fix it?
GIcon is not supported by v3?

// Google-Map icon object
var gMapIcon = new GIcon(G_DEFAULT_ICON); //change to new google.maps.MarkerImage();???
// does icon exist
if ( mapElements[lMapElementIndex]['icon'].toString().length > 0) {
    gMapIcon.image = html_entity_decode(mapElements[lMapElementIndex]['icon']);
    gMapIcon.shadow = "";
    iconHeight = mapElements[lMapElementIndex]['iconheight'];
    iconWidth = mapElements[lMapElementIndex]['iconwidth'];
    gMapIcon.iconSize = new GSize(iconWidth,iconHeight);
    gMapIcon.iconAnchor = new GPoint(0,0);
    gMapIcon.infoWindowAnchor = new GPoint(15,10);
}
    var markerOptions = { 
        icon: gMapIcon //change to image? 
     };
    var marker = new google.maps.Marker(point,markerOptions);

found from here https://developers.google.com/maps/documentation/javascript/overlays?hl=de-DE#SimpleIcons

thanks for any help or tips!

like image 273
Jim Avatar asked Jun 04 '12 15:06

Jim


1 Answers

GIcon is not supported by Version 3, and does not appear in the documentation you link to.

  var image = 'beachflag.png';
  var myLatLng = new google.maps.LatLng(-33.890542, 151.274856);
  var beachMarker = new google.maps.Marker({
      position: myLatLng,
      map: map,
      icon: image
  });

You can specify an image to use directly, you don't need a helper object like Version 2's GIcon. However, if you want non-standard sizes etc you will need to use a MarkerImage object as described in the documentation at https://developers.google.com/maps/documentation/javascript/overlays?hl=de-DE#ComplexIcons

(Version 2's GIcon has its equivalent as the optional MarkerImage in Version 3)

like image 79
Andrew Leach Avatar answered Oct 13 '22 00:10

Andrew Leach