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

Using symbol with Marker #382

Closed
farhan687 opened this issue Nov 9, 2016 · 3 comments
Closed

Using symbol with Marker #382

farhan687 opened this issue Nov 9, 2016 · 3 comments

Comments

@farhan687
Copy link

Hello there,

I want to use the symbol within marker, and I am using following code snippet:

<Marker 
              symbol={{
                  path: '<path d="M 100 100 L 300 100 L 200 300 z" fill="red" stroke="blue" stroke-width="3" />'
              }}
              ...
/>

Am I missing anything?

@mndewitt
Copy link

See the Google Maps JS API docs example for adding a custom SVG icon:

// This example uses SVG path notation to add a vector-based symbol
// as the icon for a marker. The resulting icon is a star-shaped symbol
// with a pale yellow fill and a thick yellow border.

function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 4,
    center: {lat: -25.363882, lng: 131.044922}
  });

  var goldStar = {
    path: 'M 125,5 155,90 245,90 175,145 200,230 125,180 50,230 75,145 5,90 95,90 z',
    fillColor: 'yellow',
    fillOpacity: 0.8,
    scale: 1,
    strokeColor: 'gold',
    strokeWeight: 14
  };

  var marker = new google.maps.Marker({
    position: map.getCenter(),
    icon: goldStar,
    map: map
  });
}

So something like:

const icon =
    path: 'M 100 100 L 300 100 L 200 300 z',
    fillColor: 'red',
    strokeColor: 'blue',
    strokeWidth: 3,
  };

...

<Marker icon={icon} />

...May be what you are looking for...

@farhan687
Copy link
Author

Hey @mndewitt Thanks a lot. It resolved my issue.

@tomchentw
Copy link
Owner

Please refer to Getting Help section in the README (or #469).

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

3 participants