• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Practical SVG: Google map icons

 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been using SVG icons on google maps via the Marker mechanism. This expects the path along with other properties as shown below:


Any ideas on a better way to handle this than lifting the path string out of an SVG file and hard-coding it into the code?
 
Author
Posts: 7
5
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Any ideas on a better way to handle this than lifting the path string out of an SVG file and hard-coding it into the code?



Not really! If the SVG existed somewhere else on the page, you could snag the path out of it like `path.getAttribute("d");`

Also, all those line breaks and tabs shoudn't be necessary. My guess is Illustrator exported it that way and you were trying to remain faithful to it's output by replicating the whitespace. Honestly I have no idea why it does whitespace that way sometimes. Although, it should _only_ do that when you're doing something like "Save As..." an SVG, which, IMO, is a bad idea. Like we talked about in this thread, Illustrator can export in a pretty nice way (that won't have any weird whitespace). Then just save your original as an `.ai` file, since you might as well save with all of Illustrator's native conveniences.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chris Coyier wrote:Also, all those line breaks and tabs shoudn't be necessary.


Yeah, that was a result of cutting and pasting the block and my IDE "helpfully" interpreting the whitespace for me. I should stop being lazy and remove them.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Chris Coyier wrote:Not really!


That's kinda what I figured.

If the SVG existed somewhere else on the page, you could snag the path out of it like `path.getAttribute("d");`


Hmm, I know somewhere else in my code where this would be useful. Thanks!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic