Best practices for fleet tracking using google maps v3? - javascript

I want to develop fleet tracking app using HTML5,JavaScript, Couch DB for a construction site.I ll get live lat,long of moving vehicles in json format.I dont want to use Direction Services of google since lat,long coming from our own GPS devices.I ll display vehicles as markers.how can i do this in a best way regarding following issues:
Performance
Do i need to maintain separate instance for each vehicle(if 100
vehicles are moving).
Low network speed(since construction sites locates in forest).
Please give me suggestions I ve searched in NET for 1 week but dint get anything useful.
Note:I am well aware of google terms and conditions for business.

Google maps api encourages you to use ajax which addresses performance and reduced network loads itself. If you make all the markers identical, you'll reduce the number of images that must load, but your client will not be able to distinguish the vehicles from one another. Therefore, when the locations are updated, you won't be able to tell which vehicles moved where, it'll just be a bunch of markers that randomly move. In my app, I draw marker images on the client side via canvas. This eliminates the network latency of waiting on marker images to load. I have maps where 100 different icons, each with different numbers(labels), load seemingly immediately. Another performance improvement would be to use websockets to send the updated data. You could set up an algorithm on the server side that detects movement of the vehicles and only sends data messages for vehicles that have moved. If each vehicle is given an ID in your JSON feed, you can loop through your markers(vehicles) and update the locations based on matching IDs.

Related

Client live update with socket.io

I'm having troubles chosing the best design for my app.
I'm coding a mobile app and I need to get pictures from my server, and display them using their gps coordinates attributes on a google map using markers.
So, normally I'd just GET them from my api using a simple GET /pictures, but then I thought of a better (and maybe more elegant) way to do it. I wanted to use socket.io for live updating the pictures, because when I get the pictures from the API, I don't get all of them, I only take the ones that are where the client looks on the map (using google maps' getBounds()), so GETting /pictures everytime the user changes where he looks seemed a little bit slow.
Initially, I used google maps' idle event to GET the pictures in an area.
What I would like to do now, is a live updating map using websockets, but I can't understand how I would implement it in my app. Here's the problem:
user1 gets the pictures in an area. He gets the pictures, and they are drawn on the map using markers. Ok.
user2 creates a picture, in the area user1 looks. Or even more generally: user2 makes an action on a picture user1 is looking (liking it, deleting it, creating a new one, whatever)
Now, how does user1 know that an action has been taken? The server could broadcast an emit, but then what? What about other users that aren't looking at the picture?
I just don't get how to be synchronous with the server: deleting a marker when the picture is deleted, incrementing a number when a picture gets a like. I don't get it, and I want to know because I think it would be a very good time to make a real time app, or maybe I'm forcing it and I should stick to HTTP.
I've thought of using setInterval on the client and asking for the pictures (with fresh informations on it) but I don't know if it's the cleanest way to do it.
Thank you for your time
You can still broadcast an emit using socket.io and that would be enough for users who are currently looking at the same area; but you also need to store this new information somewhere (e.g. Database) for users who are not currently looking at the same area, so that when they go to that area they would get the most up to date information from the server/database.

Leaflet adding markers on map and data security

I'm looking into using Leaflet to make maps and place markers in an internal application (i.e. not a web-site, but a simple desktop application), but I'm wondering which data is sent and which is not. Do the following command send any data or is it only plotted locally?
marker = L.marker([51.5, -0.09]).addTo(mymap);
Needless to say, I want to keep my data confidential and not send it away over the web.
(If this is the case, then any recommendation on a good alternatives).
It's all local (I use leaflet offline all the time). If you want to check the source code for markers and look for yourself, feel free to check it out here
As an in-browser javascript library, I've never come across a situation where leaflet sent data. In fact, the only thing you really need an internet connection for in leaflet is to get map tiles/images.

Try to find out if my (use of google maps API services) calculations are correct?

I am a nontechnical member (and idea leader) of a team that develop certain web application, so I am not very familiar with this area. I am asking this question here, because one or two responders here :) probably cross with this "problem" before. The problem for me is, that I dont know how to calculated the right number of requests or with other words "google maps API request and map loads usages of their services" when we would like to find out IF COORDINATE (which represent address) IS IN THE CERTAIN POLYGON OR NOT (polygons represent local areas, based on which we determin if address is in the area t or not).
My first findings were (i dont know if they are right?), that we will probably need (to find out if coordinate is in the polygon or not) to use GOOGLE MAPS JAVASCRIPT API (because we have web app and because we will get address that represents coordinate from user that is user who uses our app client-side) and containsLocation() FUNCTION from Geometry Library.
Now with all that, I assume that only "1 request" and "1 load map" through Google maps Javascript Api is taken?
Thank you.
Google Maps JavaScript API calculates only map loads. So your quota is limited to 25k daily map loads without Billing enabled and 100K daily map loads with Billing enabled.
https://developers.google.com/maps/documentation/javascript/usage
One map load corresponds to call new google.maps.Map(). If you call a function from geometry library it doesn't generate additional requests. Zoom, pan neither generate any additional request.
You will generate additional requests only if you use client side services like geocoding, directions, distance matrix or places (autocomplete, search or detail). In this case requests will be calculated against corresponding Web Service quota.
https://googlegeodevelopers.blogspot.com.es/2016/06/building-for-scale-updates-to-google.html
Hope it helps!

Google Maps API v3, what counts as a hit if I'm not geocoding?

I'm building an application that will be getting sets of gps coordinates from the database, and then converting them to an array of location objects. Then it will render a Google map using the API and put markers and pop up info for the markers at the determined locations. The user will be able to filter to different locations and different markers. In the documentation it talks a lot about query limits and how fast/how many queries you are allowed to do. Most of what I've found involves geocoding addresses though, if I'm not geocoding and just using my own coordinates for the markers, then what will be considered a query counted towards the limit? I need to make sure I'm designing this right and my company has the right access for what we need. Thanks.

Is there any way to control how often google maps updates your location?

Im developing a version of google maps for a phone application and im trying to figure out how to let the users manually update their locations rather than automatically updating(mainly for battery conservation). I searched through the new google api v3 developer page and I couldnt seem to find anything. Anyone got any ideas?
Google knows nothing about your location. There is no pull from them. Any location is given by a push from the device/browser.
There's a couple ways google knows your location.
There's HTML5 location, which is the most accurate.
This is usually the preferred way to get location.
But, as we all know, not everyone wants to do that.
Google still wants to provide a good user experience for those users.
So second way to get location, IP Location.
Ip location is correct approximately 85% of the time, depending on the database you use for it. Some are more accurate. But it usually gets within about 25-50 miles of the user location, whereas html5 location is within just a few miles of your location. I've personally had my location pulled within just a few feet of where I was.
As far as updating, I would imagine google probably updates monthly and caches the location in their system. While location is an important variable in their ads, google also has to be fast and efficient, so it's a good compromise. Unless you're using the maps feature, that already has cached hits built into each area so they can get your location and then serve you content via AJAX through their thousands of cached servers.

Categories

Resources