yretuta
yretuta

Reputation: 8111

Replicating an Icon in Google Maps API V3

I have this code written in V2 API:

// replicate a different sized icon
    var babyIcon = new google.maps.Icon(marker.getIcon());

    babyIcon.iconSize = new google.maps.Size(
        marker.getIcon().iconSize.width * this.iconScale_,
        marker.getIcon().iconSize.height * this.iconScale_
    );

    babyIcon.iconAnchor = new google.maps.Point (
        marker.getIcon().iconAnchor.x * this.iconScale_,
        marker.getIcon().iconAnchor.y * this.iconScale_ / 2
    );

however, I can't get to convert this into v3 knowing that there is no Icon constructor for the v3 API. Any ideas?

Upvotes: 1

Views: 1612

Answers (1)

Jack B Nimble
Jack B Nimble

Reputation: 5087

You want to use MarkerImage instead of Icon (getIcon() will return MarkerImage)

Here is the Reference

var babyIcon = new google.maps.MarkerImage(marker.getIcon());

babyIcon.size = new google.maps.Size(
    marker.getIcon().size.width * this.iconScale_,
    marker.getIcon().size.height * this.iconScale_
);

babyIcon.anchor= new google.maps.Point (
    marker.getIcon().anchor.x * this.iconScale_,
    marker.getIcon().anchor.y * this.iconScale_ / 2
);

Upvotes: 2

Related Questions