Google Maps

Jul 25, 2011 at 9:23 AM

Hello,I'm trying to build an html page that query an Odataservice and put the results (containing latitude and longitude) as markers on a google map. 

The main problem is that in all the examples I have seen there is a loop on the query results that append html code to some element while I need some

javascript code to generate the marker.

I'm not a Javascript expert so I was wondering if this is possibile and how.

Jul 26, 2011 at 10:18 PM
Edited Jul 26, 2011 at 10:48 PM

Hi Salvatore,

  Hope you are doing great.  You can execute any arbitrary javascript code in the success and error handlers.  If using the api directly, and assuming that there is an object representing your map named myMap (this object might have been initialized elsewhere and is in the scope chain) this would be:"uri to your map data service", 
    function (data) {
        var i, len;
        for(i = 0, len = data.results.length; i < len; i++) {
            myMap.setPinPoint(data.results[i].lat; data.results[i].long);
    function (err) {
        // do something to handle the error here.. 

  The samples use such loops and html constructs to reperesent some specific logic that the application might want to apply to the data recevied.  They are just an implmentation detail of the sample and only for doing something "interesting" with the data in the sample.  Real world applications, like the one you describe, would use whatever specific logic necessary to process and do something useful with the data received.  In your particular situation, it would be the javascript code needed to build a marker and inject it into the map :).


Alex Trigo. 


Jul 27, 2011 at 11:01 AM

Thanks for your kind help!

I succedeed in implementing what I wanted. Datajs is a very interesting project and I'll keep on watching it!