Reliable URLs for Marker Icons?

8,456 views
Skip to first unread message

Iam Anonymous

unread,
Dec 29, 2010, 6:31:17 PM12/29/10
to google-map...@googlegroups.com
I have an application that creates a map as a single html file that I want to be able to archive and to email to people.  An implication of this is that it can't reference other files because those files won't be present when the html file is opened by the recipient.

So ... now I would like to customize the marker icons.  The only way I can see to do this is by referencing web urls that will be reliable over time.  This is especially important because from testing I see that if a custom marker link is broken I don't get the default marker.  I get nothing.

I have found a couple of icon libraries at Google, like http://gmaps-samples.googlecode.com/svn/trunk/markers/ but the "gmaps-samples" portion of the link does not give me a sense of permanence.  I would like something more like "guaranteed-icons/google.com"  :-)

Is there such a thing as a permanent icon library, preferably maintained by Google?

Also, is there some way I can test a link within the Javascript to determine whether the icon is there or not?  I am relatively new to the language but if I could do this, then I could omit the "icon:" reference to a missing icon and let the map revert to the Google default.

TIA

geoco...@gmail.com

unread,
Dec 29, 2010, 6:57:01 PM12/29/10
to Google Maps JavaScript API v3
On Dec 29, 6:31 pm, Iam Anonymous <commercialpilo...@gmail.com> wrote:
> I have an application that creates a map as a single html file that I want
> to be able to archive and to email to people.  An implication of this is
> that it can't reference other files because those files won't be present
> when the html file is opened by the recipient.
>
> So ... now I would like to customize the marker icons.  The only way I can
> see to do this is by referencing web urls that will be reliable over time.
>  This is especially important because from testing I see that if a custom
> marker link is broken I don't get the default marker.  I get nothing.
>
> I have found a couple of icon libraries at Google, likehttp://gmaps-samples.googlecode.com/svn/trunk/markers/but the
> "gmaps-samples" portion of the link does not give me a sense of permanence.
>  I would like something more like "guaranteed-icons/google.com"  :-)
>
> Is there such a thing as a permanent icon library, preferably maintained by
> Google?

Nothing is permanent on the web.
Your best option is to put the icons on a webserver/url owned by you
and leave it up forever.

Google's icons have been pretty stable in a couple of places:
1. the "google earth icons" Mike Williams references in his tutorial:
http://econym.org.uk/gmap/geicons.htm
2. they have icons in several places on www.google.com and
maps.google.com which have been fairly stable, but as pamela indicated
when she provided a list:
http://groups.google.com/group/google-maps-api/msg/5a07a33dd0281b45
they could disappear at any time.


>
> Also, is there some way I can test a link within the Javascript to determine
> whether the icon is there or not?  

I have seen algorithms discussed in various places on the web, I
haven't implemented any myself as I haven't deemed it worthwhile for
my applications.
A couple that I seem to remember:
1. use xmlhttp to attempt to get the image, check its return value
2. add an onload call back to the image, verify that it happens

-- Larry

Michael Geary

unread,
Dec 29, 2010, 8:47:28 PM12/29/10
to google-map...@googlegroups.com
If you really want to include the marker icon image data directly inside your HTML file itself, there is a fairly easy way to do that: convert each image to a data: URL and use that URL as the icon image URL instead of a conventional http: URL. Simply use one of the available online image to data URL converters and copy the URL out of the src="data:etc.etc.etc." in the <img> tag they generate.

Here's an example:


View the source to how it's done - this is simply one of the standard V3 API examples with the image URL changed.

-Mike

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Chris Broadfoot

unread,
Dec 29, 2010, 11:00:03 PM12/29/10
to google-map...@googlegroups.com

Iam Anonymous

unread,
Dec 30, 2010, 6:51:20 PM12/30/10
to google-map...@googlegroups.com
Thanks, folks.  This was a big help.  Michael's suggestion was the one that fit my need the best.  In fact, it's a solution that occurred to me but I didn't know how to do it.  (I wrote this to a friend a few days ago: "AFIK the only way to do cute icons would be to send them as separate PNGs, GIFs, etc. with the web page html.  If you know a way to embed them with the HTML that would be wonderful.")

I now have the two icons I needed embedded in the file and it is working great!
Reply all
Reply to author
Forward
0 new messages