remove and add google map markers dynamically asp.net - c#

I am new to asp.net and Google maps. I want to achieve tracking capability on my asp.net page. I want to create a number of markers and then move them along a path.
Can any one help me understand, how do I do it?
I want google maps to work as AJAX

this can be done in many ways, I will dish out a very easy solution,
1.Your webpage should load a map and add markers representing your assets with an id.
2. Your web page should ping your web server every sec to query for change
3. If your server has a change to report it should reply back with the latest latlon for those ids as a json
4.you can then update the positions of those markers.
If you can implement http push(long polling/websockets) then even better as you will get near realtime updates
This assumes that your web server is being updated by your tracking device.
your webservice should always return the latest position it has for the assets.
Updating your markers(assets) on client side is pretty easy as well,
To 'move' your existing marker, you'll wanna make sure its global and then you can just update its position within the function with something like:
marker.setPosition(results[0].geometry.location);

Related

Reloading the model in the view

I have a google map that loads with markers and a route at the beginning. (MVC in .NET5)
The position of the markers changes every few seconds (it is saved on the server, the data comes from the mobile application)
I would like to download new data from the server every few seconds and update the view. (I mean refresh the data without reloading the page)
I did this by asking GET to REST in JavaScript every 5 seconds, but is it possible to do it differently?
If and how to update the model in the view to receive new data every now and then?
In the internet I find partially reloading views, but I only want to refresh the data (coordinates and other data)
I highly suggest you look into Blazor and using SignalR for this, if possible. Using WebSockets to listen for changes is going to be so much more efficient and cleaner than having an ajax call every 5 seconds.

GMap.NET + C# + postgreSQL without Internet connection

I have a desktop app in C# using GMap.NET and it's great, but my app must work without Internet. I thought, I needed kinda PostgreSQLProvider for GMap.NET.
So I downloaded an .osm file for Russian Federation, created a postgresql database with postGIS extention and then executed query, which was generated with osm2po (it's huge: 1,2 Gb)
Now I have a databese, which can be visualized with QGis. I want to visualize this database map in my C# application to handle user mouse button clicks and draw some objects on map.
How can I do that? Maybe I should use another framework? All I need from map is get placemarks in mouse button click handler function and draw objects on map.
You can prefetch the maps you want with the demo version of GMAP.NET. Then grab the database generated by the prefetch and use it in your application. its located in
C:\Users\USERNAME\AppData\Local\GMap.NET\TileDBv5\en\Data.gmdb
the Database is in SQLite but I figure you can convert it to any DBMS you want.
I found, where the problem in. osm2po generate for me vector map, but GMap visualize only raster. The solution is to use another framework, such as SharpMap, that can work with vector maps from database.
Of course, I can write my own PgSQLProvider for GMap, but I have only a month and still many other works.

Which API to use when starting with Bing Maps

I've spent most of the Christmas reading through the Bing Maps information. However, there are so many different options and choices that I'm getting stuck on the plentifulness.
In one of the most obvious URLs I see both non-API and API approaches. That's confusing. There are AJAX, REST and Spacial Services and, to the best of my understanding, they do pretty much the same. That's confusing too... :)
So, here's the question. I'd like to create a web page that given a certain input (e.g. XML or JSON) will provide me with an image. The image is supposed to be a map with plotted pins (that contain my descriptions), controls for zoom/pan and (preferably) even traveling routes (automatically computed or provided by me) between those pins. Also, It'd be great if I could set a semi-transparent polygons covering some areas.
Which API am I supposed to use?!
I sis something like that a few years ago with Google Maps but as far I recall, I only sent in a XML file and the map was hosted more or less at Google's.
If you're building a web site, then you'll have to choose between the AJAX Control and the REST services. Basically, the AJAX Control allows you to embedded a map in your page, add pushpins, draw shapes, display routes...etc.
See http://www.bingmapsportal.com/ISDK/AjaxV7#CreateMap1 for a live demo.
The REST services are more useful for tasks simple like static imagery as well as requests like (reverse)geocoding and routing, that don't involve user interaction.
If you want a full "map control" that allows the user to interact with keyboard/mouse, use the AJAX API. If you're not, REST services could be enough.
EDIT:
AJAX API = AJAX control = AJAX v7
Spatial Data Services is a REST API that allows to compute spatial requests against a large number of data. It shouldn't be used to display a map.
If you're interested in something that allows your users to pan/zoom, create pushpins by clicking on the map...etc., then the AJAX control is the most suitable. It offers all the javascript stuff to display a dynamic map that allows user interaction.
If your XML file is in GeoRSS or GPX format then take a look at the modules for Bing Maps here which show you how to do this in a few lines of code: https://bingmapsv7modules.codeplex.com/
If your XML file is a custom format then take a look at the GeoRSS module to see how to read XML in JavaScript.
If you have more than a thousand items in your XML file I would highly recommend storing your data in the Bing Spatial Data Services which will expose it as a spatial REST service, or uploading it to a database and using a web service to load the data to the map. Loading more than 1,000 pushpins to a JavaScript map could be slow. Using a service you can load only the data that is in view which would make your app much faster.

Google Multiple Markers Mapped in Sequence

I am using the example Google Maps API V3 for ASP.NET on Code Project and it works very well.
I'd like to add a little functionality to it but I'm not sure it is possible. I have done some research but I'm not sure what I the terminology for this is.
We have a lat/lon being reported to our SQL Server every 15 seconds. I'd like to take a reading at every minute and map the route where the vehicle has gone for x number number of readings
I can put pins on the maps with lat/lon without a problem but I'd like to show the route that it went, with lines or something to the like.
Is this possible with Google Maps?
Sure. In the Google Maps API, these are called Polylines.
Here is a link to the documentation:
https://developers.google.com/maps/documentation/javascript/reference#Polyline
And here is one of the developer samples using Polylines:
https://google-developers.appspot.com/maps/documentation/javascript/examples/polyline-complex

Show values from database on canvas

I have a website which shows imes, personal records, results, limits, etc for Dutch swimmers.
On of the things i would like to add is a graph showing the progression of the swimmer over time for a certain stroke/distance.
For this i would like to use the HTML5 canvas.
I did some tutorials, read some sites and i am able to draw a nice graph via javascript.
But now : how to get both the database and (probably) javascript to work together ?
How do i get the values from my database to the javascript function, so it can draw the chart on my canvas ?....
Put the database on the server. Add a script (php? Python? whatever your webserver has) to retrieve the values from the database via SQL and turn them into JSON (javascript object notation).
In your javascript, make an AJAX script to the server's data page described above, and voila, data in the browser.
The main problem is that javascript (particularly in a browser) is expected to come from, and communicate with, a server. It doesn't really have client-side database connection libraries.
If you want to do it all client-side, then I suggest you ignore canvas and html, and go with the c# option.

Categories

Resources