DanTheMan
DanTheMan

Reputation: 3277

Google maps: can you embed more data in the polyline than lat/lon?

I know you can get the Lat/Lon back from a polyline through the click event.

However, all my data is keyed by TIME, not Lat/Lon. There's likely too much data to go through to search for a particular lat/lon, too.

Can I add any information to the Polyline so that it gives me back some key (ideally time) that I can then search through and find the rest of my data?

All my research says no, without pulling all the data out and re-keying it, or simply brute-force searching my db.

Upvotes: 3

Views: 255

Answers (1)

Duncan_m
Duncan_m

Reputation: 2546

You're in a javascript environment... GPolyline and other overlays are javascript objects. It is entirely correct and possible to add your own properties to these overlays when you add them.

So you can do:

myPolyline = new GPolyline(latlngs);
myPolyline.myspecialtimevalue = sometimevalue;
map.addOverlay(myPolyline);

In the click event that you register you can then happily examine .myspecialtimevalue on the clicked polyline.

Duncan.

Upvotes: 2

Related Questions