All posts by matt

How to dynamically choose the color of your Google maps marker pin using javascript

You can dynamically request icon images from the Google charts api with the urls:

http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|FE7569

Which looks like this: default the image is 21×43 pixels and the pin tip is at position (10, 34)

And you’ll also want a separate shadow image (so that it doesn’t overlap nearby icons):

http://chart.apis.google.com/chart?chst=d_map_pin_shadow

Which looks like this: shadow the image is 40×37 pixels and the pin tip is at position (12, 35)

When you construct your MarkerImages you need to set the size and achor points accordingly:

var pinColor = “FE7569”;
var pinImage = new google.maps.MarkerImage(“http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|” + pinColor,
new google.maps.Size(21, 34),
new google.maps.Point(0,0),
new google.maps.Point(10, 34));

var pinShadow = new google.maps.MarkerImage(“http://chart.apis.google.com/chart?chst=d_map_pin_shadow”,
new google.maps.Size(40, 37),
new google.maps.Point(0, 0),
new google.maps.Point(12, 35));

You can then add the marker to your map with:

var marker = new google.maps.Marker({
position: new google.maps.LatLng(0,0),
map: map,
icon: pinImage,
shadow: pinShadow
});

Simply replace “FE7569” with the color code you’re after. Eg: yellow

My next e-book

If you know me, you’ll know I just got back from a year galavanting around the world. I was given a Sony e-book as a present which I took with me, and soon became an essential item.

It’s already showing its age compared to newer models but I’m not buying a new one until e-book manufacturers start adding features I actually want.

I don’t want:

  • A colour screen. Why would I? I just want a book
  • Video support. If I wanted an iPad, I’d buy an iPad. I just want a book.
  • A qwerty keyboard. I have a phone for web and email. Did I mention I just want a book?

I want:

  • A big screen. Y’know, about the size of a book. With the best resolution you can please.
  • Amazing battery life. My current e-book is fine but more is always welcome. If the battery won’t easily last a week, then a book wins.
  • Tough construction. I don’t want to feel I have to buy a leather case to protect my delicate gadget and then just worry about it in my backpack. Make it tough so I can just chuck it around. Like a book.
  • Water-proofing. This is the killer feature. I want to read on the beach and in the bath without worrying about it. Why isn’t there a bright yellow* ‘sport’ edition like the walkmans of the 90’s?

I already prefer my e-book to real books. It’s a no-brainer for me, I’m converted. But if you’re a manufacturer and you want me to upgrade, make a model with features I actually care about.

*Yellow would obviously be an awful colour for a book. Black or white would probably sell better but frankly, I don’t care**.

**I’m lying, of course I would care. How about carbon fibre? Transparent plastic? Metal covered in that rubber they make Aerobies with?