Posts Tagged google visualization

Posted on Programming

Adding text to google maps markers

If you’ve ever used the Google Maps Javascript API, you’re probably aware that marker labels can only be one letter long. But sometimes you want them to say something meaningful, and often that takes more than a single character.

In case you’re looking for a way to display arbitrary strings in a Google Maps marker, good news, here’s how you can do it!

You can pass a data URL when you’re supplying an image for an marker, which is great. We can send it some SVG which includes our label text.

  1. Import your marker icon into Illustrator, or some other vector graphics software.
  2. Type in some sample text, formatted however you like.
  3. Export it as SVG.
  4. Create a function that replaces the sample text with whatever you want to display, and returns the adjusted SVG
  5. Pass that to the Google Maps API as a data URL.

// Generate a pin!
function createPin(text) {
var svg = '...'; // Imagine there's SVG here.
return 'data:image/svg+xml,' + svg.replace('sample-text', text);
}
// Create the map. Position and style it however you like
var map = new google.maps.Map(document.getElementById('maps_marker_text_example'), {
center: {lat: 49.264691, lng: -123.100},
});
// Create the marker
var marker = new google.maps.Marker({
map: map,
icon: createPin('delicious burritos'), // Generate the SVG for this marker
position: {lat: 49.2630584, lng: -123.0945}
});

Bam! You’re done. You’ve got map markers showing custom text.

One thing to be aware of is the <svg /> tag must include width and height attributes, otherwise weird things will happen. When I exported from Illustrator, my file had a viewBox attribute, but no width and height. So if yours is missing those, add them in.

 

Posted on Uncategorised

Airtime data 2

I’ve added this last month’s data (up to November 17th) to my database of airtime usage. I also adjusted the script to automatically generate the answers for me – instead of summing and averaging manually.

I also noticed that Koodo does something strange! Jt’s calls often come in as private, so the number they’re from won’t be in my usage logs. Koodo logs those calls as from my phone number!
This may be what all or most phone companies do, but it’s still strange.

I rarely get a private call from anyone other than Jt, and when I do they are either very short or “missed”. I’ve had it add those entries to his minute bars.
Once I did that, his minutes jumped way up, and it became pretty clear that I speak most with him.

For phone usage graphs, this is a mistake. I should display those as either private or me. I doubt they would count as his number in any sort of plan optimization I could do.
(more…)

Posted on Uncategorised

Airtime data

My phone’s been surprisingly resilient. It’s suffered such remarkable damage at my hands and, it has its quirks, but still basically works. It’s impressed me.

I have a Motorola Krzr K1, and it’s not particularly smart. I can’t be certain how long I’ve had it, but if sure feels like it’s been a long time. (Honestly, I could probably check.)

I’ve always secretly planned to get a new phone one day. Probably featuring Android. It may not have been much of a secret. In fact, I imagine it’s probably a fairly normal dream.

But a dream was all it was, I was comfortable waiting for a good month-to-month plan and, ideally, for Android 3.

And then a terrible things happened. My phone stopped working for over sixteen hours. Android 3 was months away, and talk and data plans were worse than ridiculous, while contract-free data plans were difficult to find. It’s fair to say that I panicked, and when I panic even fairer to say I sometimes take things too far.

With such terrible options, it seemed more important than ever to customize a plan to my usage so as not to get owned in the wallet every passing month. The various plans seemed to offer the inclusion of one in three features: a small number of free numbers, a low constant multiple applied to your anytime local minutes, or extended evenings and weekends. I wasn’t sure which would most benefit my usage tendencies, and I wasn’t at all convinced that my actual matched my imagined use.
(more…)