This is a migrated thread and some comments may be shown as answers.

How to move a map marker

12 Answers 214 Views
Map
This is a migrated thread and some comments may be shown as answers.
Warren
Top achievements
Rank 1
Warren asked on 29 Jun 2015, 01:00 AM

After I add a few markers is there a way to move the markers based on a new GPS location? Basically I want to bind the map to a datasource and show the markers. But I may add and/or remove markers being returned. When a marker is not returned is it removed from the map? And how are the markers moved? Are they just cleared and moved based on what is in the recordset returned?

Thanks,

Warren

 

12 Answers, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 01 Jul 2015, 08:27 AM
Hi Warren,

The described situation is entirely dependent on how datasource is being changed/modified. Further, teh Map should be only rebound. Although, if you are using RadClientDataSource control for data binding, RadMap should automatically detect changes done to the datasource and rebind the markers.

Therefore, to properly get a proper answer to your question it is best to first define what is the data binding technique used, and how the markers' data would be modified by the client.

Regards,
Ianko
Telerik
0
Warren
Top achievements
Rank 1
answered on 01 Jul 2015, 12:35 PM

That s excellent. Thanks! So if I remove and add markers to the SQL table while using the amp and a datasource those new markers will then show and others will be removed when I rebind the markers?

 I will give this a try. Now I just need to look into the popup window for the markers to show information and see if I can add a button to the popup to do something such as view the details of the selected vehicle.

Warren

 

0
Ianko
Telerik team
answered on 01 Jul 2015, 01:46 PM
Hi Warren,

You can examine in this demo (http://demos.telerik.com/aspnet-ajax/map/examples/data-binding/dataset/defaultcs.aspx) how to add HTML templates as tool tip content, thus, to add HTML button, anchor or whatever you would need.

Regards,
Ianko
Telerik
0
Warren
Top achievements
Rank 1
answered on 04 Jul 2015, 04:10 AM

One question.. I created an aspx page with the map and I set the datasource to show markers from a table and it works great. I then added a timer on the page to rebind every 10 seconds. It displays fine on my pc but when I call the web page on my mobile app and show the web page in a webview control the page flashes when it rebinds. The page actually clears for almost a second while it rebinds. Do you know of any way to rebind without having the page flash like that? Even if I put it inside an ajax update panel won't it do the same?

Thanks,

 Warren

 

0
Warren
Top achievements
Rank 1
answered on 04 Jul 2015, 04:25 AM

To see if it was the web browser control in my mobile app or if it was the website I loaded the web page url into Chrome on my Android phone and it does the same thing. It flashes the whole map away and back when it is rebinding. I am calling databind on the map like this:

 RadMap1.DataBind()

I am doing this with a timer control. Is there a better way to do this so the whole page does not flash? The reason I am binding again is the location of the markers will be changing in the sql table and I need to pull them and update the markers on the map.

URL: www.5ttechnology.com/tmap/map104.aspx

Thanks,

Warren

 

0
Ianko
Telerik team
answered on 06 Jul 2015, 07:15 AM
Hi Warren,

The shared site does not open on my end.

Did you try using AJAX to update the map?

Can you provide a sample code to show what it is implemented?

Regards,
Ianko
Telerik
0
Warren
Top achievements
Rank 1
answered on 06 Jul 2015, 12:44 PM

I just restarted the server and the site is coming up fast now.

http://www.5ttechnology.com/tmap/map104.aspx

What do you mean update with AJAX? I am using an ASP.NET timer and calling the DataBind method. I have a sqldatasource on the page that the map is using. How can I rebind with AJAX without the postback or showing it where the browser does a whole refresh and flashes like that?

I can post the code but the web.config has my sql server connection in it. Still post it and remove that? Or I can email it to you and you can try with the connection string.

Thanks,

Warren

 

0
Warren
Top achievements
Rank 1
answered on 06 Jul 2015, 05:44 PM
Btw, the map may react different depending on what browser you use. In some cases I do not see it show a flash from redrawing the map on one browser and then on another it does show more.
0
Ianko
Telerik team
answered on 07 Jul 2015, 04:05 AM

Hello Warren,

The map flickering is exactly due to the post back. If you implement logic that updates the RadMap via AJAX-controls (i.e., UpdatePanel, RadAjaxPanel or RadAjaxManager), the map will be updated without reloading the entire page. You can examine this demo—http://demos.telerik.com/aspnet-ajax/ajaxmanager/application-scenarios/ajaxify-timer/defaultcs.aspx.

Regards,

Ianko
Telerik
0
Warren
Top achievements
Rank 1
answered on 18 Nov 2015, 06:03 AM

I know this is a late reply but yes I used your example and it works nice. The map no longer flickers and the entire page does not reload.

 I do have one question. I have the markers being called in the sqldatasource which is assigned to the map. And they do show on the map. So if I want to move a marker I just change the lat/lon in the table that is returning the marker. Is this the best way to do this? The only part I hate on this is the markers flash on each update which I assume is because each one is reset with the databind.

Thanks!

0
Ianko
Telerik team
answered on 18 Nov 2015, 03:09 PM
Hi Warren,

I am somehow confused about the exact situation. 

If the the map markers should be updated when the table is changed, what alternative could be available to achieve this task? I am unable to consult you on that because this entirely depends on the application requirements.

Also, if the marker is replaced according to new data from the server, I do not see how marker's flickering or flashing would be prevented as the entire DOM element is placed to a different position.

At all, I am quite confused on what the final results should be and what are your exact concerns on the matter. It is merely difficult to discuss programmatic tasks without sending some examples or code snippets of the troubles you encounter. 

Also, when it comes to such tasks, it is best to be handled manually as they should be implemented according to the exact needs and requirements.

Regards,
Ianko
Telerik
0
Warren
Top achievements
Rank 1
answered on 25 Nov 2015, 06:41 PM

I remember when I was trying to use the Google mapping and they had a method to move the markers. Basically when a marker was added it was saved in a collection and rather than just reload the markers you could then work with individual markers in the collection such as moving, removing, etc. So I was hoping that once I added a marker I could just move it. But from looking into this more I assume when the marker locations are binded say every 15 seconds it is going to remove all current markers and add them again with the new location.

Thanks!

 

Tags
Map
Asked by
Warren
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Warren
Top achievements
Rank 1
Share this question
or