Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting marker icon 'anchor' #55

Closed
stevesims opened this issue May 13, 2014 · 15 comments
Closed

Setting marker icon 'anchor' #55

stevesims opened this issue May 13, 2014 · 15 comments
Milestone

Comments

@stevesims
Copy link

With the Google Maps JS API, one can set the anchor point of a marker icon to be something other than the bottom centre of the icon image. You'd do this by doing something like:

        this.homePin = new google.maps.Marker({
          position: latLng,
          map: this.map,
          icon: {
            url: "images/pin-only.png",
            anchor: new google.maps.Point(8, 8),
          }
        });

(My pin-only.png is 16x16, so the anchor on the icon is the middle of the icon.)

This doesn't seem to be supported by the plugin.

In my app I'm drawing a circle with the radius of the accuracy of the home location at latLng, and then placing the homePin on top of that. As I can't adjust the anchor point of the marker icon, the marker sits above the centre point of the circle, which looks slightly odd.

@jskidd3
Copy link

jskidd3 commented May 13, 2014

Hi @stevesims,

Have you fully reviewed the documentation for anchor points? I have achieved this with the code written below.

Example:

this.map.addMarker({
    icon: myIcon,
    position: myPosition,
    title: "Title",
    snippet: "Snippet",
    flat: true,
    rotation: myBearing,
    anchor: [17, 60]
}, function(marker) {
    alert("Yay, a marker with an anchor!");
});

@stevesims
Copy link
Author

Yes I have.

No matter what values I provide to that anchor, the position of the icon for me is not affected (on iOS).

The implementation code for setAnchor in Marker.m seems to indicate that this setting should affect the position of the info window, rather than the position of the icon. However createMarker does not do anything with that "anchor" data, so it just gets ignored.

@jskidd3
Copy link

jskidd3 commented May 13, 2014

I have just experimented a little more and it seems I was mistaken!

I suppose as a temporary solution, one could change the position of the marker in the file (for example, I have extended the transparent space in my PNG file so that it sits in the centre), but yes, I think this is certainly something that needs to be reviewed.

@wf9a5m75
Copy link
Member

Thanks @jskidd3 for your help.

Although I've never added the anchor property for the icon option, but I will implement this in the next version.

@wf9a5m75 wf9a5m75 added this to the v1.0.12 milestone May 13, 2014
@jskidd3
Copy link

jskidd3 commented May 15, 2014

Yes, my apologies, I didn't realise but pure coincidence was just giving me the impression the anchor was working for the icon, didn't realise it was the infowindow!. When will 1.0.12 be released? We have circular markers in our application also and this plays a key part. Can you make it so that if we do set an icon anchor, the rotation property makes the icon spin around the anchor point?

Thanks

ghost pushed a commit that referenced this issue May 16, 2014
@wf9a5m75
Copy link
Member

@jskidd3 You can rotate the icon using marker.setRotation(degree) in the current version (v1.0.11)

@jskidd3
Copy link

jskidd3 commented May 16, 2014

Sure you can but its based around the bottom centre of the marker. Let's say for example I have a circle, if I set the anchor to the centre (which I can't do yet, I can only set the anchor of the infowindow), the marker should rotate around the centre point (the anchor), does that make sense or should I draw a diagram?

@wf9a5m75
Copy link
Member

In your case, do you just need to the anchor property, don't you?

@jskidd3
Copy link

jskidd3 commented May 16, 2014

Isn't that just for the infowindow or does it effect the rotation of the icon as well?

@wf9a5m75
Copy link
Member

The anchor of the icon property in the next version.

map.addMarker({
      'position': GOOGLE_TOKYO,
      'icon': {
        'url': 'www/images/google_tokyo_icon.png',
        'anchor': [10, 20]
      }
    });

@jskidd3
Copy link

jskidd3 commented May 16, 2014

Perfect, is it a possibility 1.0.12 will be released this weekend?

On 16 May 2014, at 22:14, Masashi Katsumata notifications@github.com wrote:

The anchor of the icon property in the next version.

map.addMarker({
'position': GOOGLE_TOKYO,
'icon': {
'url': 'www/images/google_tokyo_icon.png',
'anchor': [10, 20]
}
});

Reply to this email directly or view it on GitHub.

@wf9a5m75
Copy link
Member

I'll make an effort as much as possible.

@jskidd3
Copy link

jskidd3 commented May 16, 2014

Cool thanks dude!

On 16 May 2014, at 23:18, Masashi Katsumata notifications@github.com wrote:

I'll make an effort as much as possible.


Reply to this email directly or view it on GitHub.

ghost pushed a commit that referenced this issue May 17, 2014
ghost pushed a commit that referenced this issue May 17, 2014
ghost pushed a commit that referenced this issue May 17, 2014
@wf9a5m75
Copy link
Member

I released the plugin version 1.1.0 (old version name v1.0.12). Please uninstall the plugin, then install it again.

ghost pushed a commit that referenced this issue Mar 1, 2015
ghost pushed a commit that referenced this issue Mar 1, 2015
ghost pushed a commit that referenced this issue Mar 1, 2015
ghost pushed a commit that referenced this issue Mar 1, 2015
@nexorianus
Copy link

yes, I know... this is a really old issue, but any chance, that this property didn't make it into the documentation?
I can only find the infoWindowAnchor property in the Marker Docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants