How to search for markers already created on a map - Google Maps

Asked

Viewed 319 times

5

I have a map where there are already loads of Markers. In this map I need to fetch all markers, and show a list with markers visible to the user, to make a small list of data similar to this example.

How can I upload all markers created on the map to a javascript variable?

Ps.- I am working on outsystems, and do not give me the possibility to install third party Apis beyond Google Maps.

  • I’m not a google-maps expert @Cesarmiguel, but I’ve used Places API maps for detailed information on a particular location.

  • @Lucascosta I am working on outsystems, do not give me the possibility to use other API’s besides google maps. Thanks anyway

  • The Places API is from Google and used together with Google Maps, use the same database..

  • Put your code that mounts the Map there.

  • What listing do pins appear on the map? Have you been able to insert markers on the map?

  • @Gumball the map is created by an outsystems component, where I send only the addresses and the component creates the respective markers

  • @Miguel the pins are the markers. Yes, the map already has the pins, I just really want to get them in javascript

  • Ha ok, I understand but how are you inserting them? No longer have the location since the beginning? Or they come from the client side dynamically?

  • @Miguel, it’s like I told Gumball. I’m inserting markers from an Outysystems component, where I just send the address and do it all myself. Basically now I want to search all markers already created in a javascript map. It’s like a map with markers coming from the client side

  • Okay, so if I understand correctly, you need to put an ajax in there to send all the markers to the server and put them in a file or a database... If you only want each other’s coordinates, one

Show 5 more comments

1 answer

2

Try to do so:

var Bounds  = osGoogleMap.OSMaps.DublinTheme_wt106_block_wtMainContent_Google_Maps_wtMap_block.getBounds();
var Markers = [];

for(var i = 0; i < markers.length; i++){
   if(Bounds.contains(markers[i].position))
      Markers.push(markers[i].title);
}

console.log(Markers);
  • The map must have a Bound created? map.getBounds('BoundTeste').contains(map.getMarker(i).gMarker.position) error: contains is not a Function

  • Dude, it would be nice to see your code. There’s no way to post ? If it was a Map created by the Google API, it’s supposed to have the getBounds. Put the code you are doing, please. So it is easier to help you.

  • I leave an example of how in outsystems I have to check if a Marker exists on the map (not doing for all markers): osGoogleMap.OSMaps.DublinTheme_wt106_block_wtMainContent_Google_Maps_wtMap_block.getBounds().contains(osGoogleMap.OSMaps.DublinTheme_wt106_block_wtMainContent_Google_Maps_wtMap_block.getMarker("DublinTheme_wt106_block_wtMainContent_Google_Maps_wtMap_block_319d74db-37cf-4940-b497-b120f3539420").gMarker.getPosition())

  • Okay, so how do I get the markers? Use osGoogleMap.OSMaps.DublinTheme_wt106_block_wtMainContent_Google_Maps_wtMap_block.markers?

  • Dude, it’s inside the For. It will go through the instances of Bounds and catch all the markers. Isn’t that what you want ? You read the code ?

  • Li... but you’re instantiating the markers on For, correct? It has to be initialized somewhere

  • How so which side ? Just put the markers inside an array and you already have them all.

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.