Update / reload maps: Google maps API V2

I am showing some marker on my google map retrieving some points from the database. Here I can add some new points or delete some points in my database. But my problem is that new points are added to the database, the map does not display updated points on the map, since it does not update. I do not want to refresh the entire web page. Here is the link of my work -

http://128.233.104.33/passgui/editLeveledit.php

What I want -

- to show the newly added data on the map when I click add new POI

- If I delete one POI, it should also be deleted from the map as soon as you remove the POI button from the level table.

Can anyone help me out?

+6
source share
3 answers

A good strategy would be to save all of your current gmarker into a javascript array. First, if you delete or add a new gmarker that you delete or add to your array, then delete each gmarker on the map (clear the map), and then you want to scroll through the array and redraw each gmarker, if you delete or add onClick, the event is fired .

0
source

Here is an extensive link to the Google Maps API v2: http://econym.org.uk/gmap/

Look at part 11 "from the" Fundamentals "section. Points are deleted / added by clicking on the buttons. New coordinates are extracted using Ajax, a bit. I'm sure you can control it in another way. :-)

0
source

DEMO: http://so.devilmaycode.it/refresh-reload-maps-google-maps-api-v2/


all you need is inside the source, look and let me know.

basically the demo uses markermanager.js lib, as it is now, it explains how to refer to newly added markers and how to insert and remove them without updating the current map / page;

the process behind is simple, every time a marker added to the map using addMarkers func, it creates marker.object , the property we are looking for, marker.no , which is in the form of marker# where # is an incremental number, so it can be any number.

now the real trick here is to create a global array where we save all the created tokens for easy access.

So, we can achieve and remove each individual marker using the removeMarker function, for example: removeMarker(global_marker_array[marker_id]); where marker_id is marker.no ;

I think this approach is really good, because you do not need to know the lat and take a long time to search for tags a second time.

0
source

Source: https://habr.com/ru/post/893727/


All Articles