PDA

View Full Version : Google Map w/text markers.



bwags
12 Apr 2012, 7:23 PM
So I've been fighting for a while with google maps and kml's. In the end it turns out that google does not provide as a part of their api a way to attach a label to a point if you are requesting that they parse your kml into a google layer. (Sorry if that didn't make much sense...it's late)

In the end I think this is how I'm going to come about my solution.



var googleMap = this.getTheMap().getMap();


var latlng = new google.maps.LatLng(40.4587914, -90.7151437);


var image = new google.maps.MarkerImage(
'/MyApp/resources/images/texxxt.png', new google.maps.Size(
100, 20));


var marker = new google.maps.Marker({
position : latlng,
map : googleMap,
icon : image
});



Feels hacky and way more heavyweight than google just reading the name attribute of my kml item and dropping it onto my point like it apparently does for something similar. Plus now I have to create a text png for 60+ items....boo.

Let me know if you have a better way!

bwags
14 Apr 2012, 11:54 AM
Found this article and modified the solution a little to fit my needs. This is a much better way to add text to a marker than providing text as an image.

http://blog.mridey.com/2009/09/label-overlay-example-for-google-maps.html

A (http://blog.mridey.com/2009/09/label-overlay-example-for-google-maps.html)ny one have a good solution for creating a marker w/out a marker?

bwags
25 Apr 2012, 6:22 AM
I did some really quick/basic testing and created 100k markers w/a 1x1 transparent png and got better results than by creating 100k markers w/an invalid image reference.