Google maps script is not loading all markers

gmorales
Kilo Expert

Hi everyone I'm having the following issue, I'm currently creating a Google Map Page in Service Now, the script that I'm currently using is similar to the one at the wiki page (http://wiki.servicenow.com/index.php?title=Using_Map_Pages) I just changed the query in order to find open incidents from a singular user, the Issue is that "counts" are displaying in the correct cities or areas on the map, but there are only 1 marker , if you click on one of the numbers the Google maps,the info windows shows up in the same place, it overlaps with previous info windows, please see my attached image to understand this behavior.(try to zoom it , and you will see 2 info windows)

var uri = gs.getProperty("glide.servlet.uri");

var count = new GlideAggregate('incident');

count.addQuery('state', '1');

count.addQuery('user_id', '=', 'ITOC.admin');

count.addAggregate('COUNT', 'location');

count.query();

while (count.next()) {

      var loc = count.location;

      var locCount = count.getAggregate('COUNT', 'location');

      if (locCount > 0) {

              var item = map.addItem(count);

              item.latitude = loc.latitude;

              item.longitude = loc.longitude;

              item.marker_label = locCount;

              item.label_offset_left = -4;

              item.label_offset_top = -20;

              var link = 'href=' + uri + 'incident_list.do?sysparm_query=active%3Dtrue^location%3D' + loc;      

              item.html = '<a ' + link + '>' + loc.getDisplayValue() + ' (' + locCount + ')</a>';

              item.icon = "images/red_marker.png";

              item.icon_width = 24;

              item.icon_height = 24;

      }

}

This is how actually is being displayed...

ServiceNow Development.png

This is what I was expecting.. .

Capture.PNG

1 ACCEPTED SOLUTION

This is a new issue and related but different:


PRB607063 :Google maps API 3.14 deprecated - Only one marker is placed on map


This affects all versions of the platform.


(Note: This is a separate issue from PRB597310 / KB0538622 which exhibits the same symptom)



Workaround:


------------------


- Navigate to Table cmn_map_page > Open the record you want.


- Add this line to the script in the while loop. Note : if you have more than one while loop in the script logics to show the map icons, then the below line should be added to all the while loops.


item.marker_label = "<img src='https://maps.google.com/mapfiles/marker.png'/>";




There is no fix, only this workaround.


View solution in original post

11 REPLIES 11

No. Hi is the ServiceNow Support site for your instance. You really should have access if you develop.



As far as I know there is no other way. I resolved my issue with this update. However, I seem to be having this issue again... I will be calling them in a minute after I open another ticket.


Ok , thanks for your Help Joel


This is a new issue and related but different:


PRB607063 :Google maps API 3.14 deprecated - Only one marker is placed on map


This affects all versions of the platform.


(Note: This is a separate issue from PRB597310 / KB0538622 which exhibits the same symptom)



Workaround:


------------------


- Navigate to Table cmn_map_page > Open the record you want.


- Add this line to the script in the while loop. Note : if you have more than one while loop in the script logics to show the map icons, then the below line should be added to all the while loops.


item.marker_label = "<img src='https://maps.google.com/mapfiles/marker.png'/>";




There is no fix, only this workaround.


You can try this but I just did and now my markers are in the wrong places. They are off place by quite a bit.



If you do want to test this, it is easy to check and easy to remove.


Hey Joel,


I appreciate your help and interest on solving this issue, Thank you so much, your workaround works like a charm.



Kind regards