Use two data sources to populate a Google map

I have a Google map working nicely and all the markers are there from my query. But I want to add another set of markers to the same map using a different query which is structured slightly differently. I thought it would be a simple process of adding another dynamic markers to the page but I now realise they are part of the map and there’s only provision for one data source per map.

What’s the best way to achieve this? I’m reluctant to redo all my query (it’s quite a complex one) to include both sets into one output so I’m hoping there is another way.

Hey Jon,

I haven’t used google maps and the markers but I think that you could just join these 2 queries in your api with the server arrayList and come up with a new joined query (arrayList)…
Is that doable for you?

Thanks @famousmag. Yep, that was my kind of last resort option. I was hoping I could just have two separate sources and have both populate the one map.

I know is a little more work for you but I think you can get exactly what you want this way!
Let’s see if anybody has another suggestion on this one…

1 Like

Yep, it’s a good soluton and will be worth it. It would just be nice to leave the existing one alone and add a second one rather than modify the original.

Oh yeah… That;s what I always do…
Never destroy or delete something that I I put effort on!!
(keep it somewhere and maybe I find it in time of need)

1 Like

Have you checked this?

Thanks @Teodor. I did look at this as I thought it might be the solution but I don’t think it will help me in this case.

Imagine two tables - customers and suppliers. Both tables contain data including the longitude and latitude values. I want to show all the records from both tables in my map.

Will the Join action allow me to do this? It looks like I have to have a common field linking the two tables (an id in the example shown) but I won’t have that.

Maybe a UNION SELECT in a custom query?

SELECT customer_name as title, lat, lng from tbl_customers UNION SELECT supplier_name as title, lat, lng FROM tbl_suppliers

You can add in whatever fields you want, as long as there are the same number of columns in each select

1 Like

In this case it won’t work. You will either need to create a custom query, which gets the records as you need or create a database view which does this and then use it as a data source.

1 Like