html5 geolocation search within radius - javascript

I can use html5 API in conjunction with Javascript to get the longitude and latitude of user. I want to take this one more further step, I want to make a search query -something like Tinder the mobile app-- to run and search for other users within a certain radius, say like run a search from my registered location to search within an 800 meters around my position for other registered locations of other users.
Any idea how to make that ? I'm a novice in php, ajax and javascript, please try to explain in simple terms.

You are looking for the haversine formulae
Check this webpage for a Javascript application of it

Related

Checking if object in Open Street Maps is a building

I'm using Leaflet library in my ReactJS app and I wonder if there is a simple way to recognize if object clicked by user is a building.
Idea that came up to my mind is to check map colour under clicked position.
Does it make sense?
I appreciate your help.
Colleagues in comments advised to give some use-case:
App I'm working on is meant to mark antique buildings with elevation in bad shape so city architecture management had simpler job of searching for them.
Every user of this App can mark such building. To prevent hooligans from corrupting data with senseless points on map I wanted to validate as a first step if clicked point is a building.
I hope it will clarify problem a little bit.
I wonder if there is a simple way to recognize if object clicked by user is a building.
No.
You basically want to run arbitrary point-in-polygon queries against OSM's building dataset, and I will presume that you don't want to host that dataset yourself.
The simplest way to do this is to perform queries to an Overpass API server, passing a is_in query and filtering by the building tag key. The OSM website's query feature functionality uses such a technique.
With this technique you won't have to worry about hosting the data, just about creating the right Overpass API query. Please bear in mind that the Overpass API servers are run by volunteers and their resources are limited.
The second simplest way would be to download a OSM extract of you area of interest, and run the point-in-polygon queries yourself, by whatever means you like (PostGIS' ST_Intersect, turf.js, etc etc).
If you will be using Leaflet, another approach would be to use vector tiles, and set it up in such a way that the buildings thematic layer is interactive. This will require you to be aware of the limitations of the vector tile servers.
Idea that came up to my mind is to check map colour under clicked position.
That is unreliable. Think about labels on top of buildings, or the colour of the edge of the building area, or buildings that don't render with the standard colour (e.g. places of worship, monuments).

How to simulate position tracking of an iot thing?

I need to simulate the position tracking for my 'IoT thing' in my IoT platform Thingworx. For eg: If I have a car as a Thing, and it has two modes moving and stopped. I need to simulate the changing latitude and longitude for the car when it is in 'moving' state and store the generated coordinates so that they can be later displayed on the Google map widget in the mashup. Similarly, if the car is stopped then it should display the location where it was last stopped. I have the following questions:
How do I achieve this? As in, should I create and use a service or a subscription (with speed values as the trigger)?
What sort of code snippet will be required for such a functionality?
Should I employ the Google api?
Also how do you store the changing values of the lat/long in the variable which has a datatype 'Location'?
Thanks!
A part of the logic to simulate movement, which can be as complex as you want or a simple as adding Randomly movements to the Latitude / Longitude.
You should use a Timer Thing which for instance triggers every second ( or any other frequency ) and you subscribe to "Timer" event and there you write the code to move the car.
You need to have a property on the Car Thing that we can call it "location" which of baseType LOCATION, and this property should be set as "logged" then you just need to update location property with the new location ( if it moved since last location - on your simulator code - ). Of course you also must set car Thing's ValueStream property in order to get storage for location changes.
You can use TW Marketplace Google Maps extension in order to show Location and Paths on Google Maps from the recorded simulation.
Setting a location property in TW it's something like:
me.location = {
latittude: latitude_value,
longitude: longitude_value,
elevation: elevation_value,
units: "WGS84"
}
Hope it helps.
What you ask for is not easy to explain in a few words! The best way is to show you an example that uses the Google Map API and may interest you also as it uses CSS transitions to smooth the trip of you car (or Hansel and Gretel in my case).
You can see the fully documented code for the Brotkrumen Web App here. It includes a aaa_readme.txt
Note that knowing when someone has stopped is not straight forward and has to be obtained heuristically. I provide a number of secs parameter that must elapse sans interesting movement-change to work out you've stop and for how long. Try running Brotkrumen in your car and it should work out when you were at the lights (At least in Perth they take forever) and will show you when you press the Map Trip or Replay button.

how to take input from a user on a google map of a boundary he/she draws

I am developing a website and I am a very beginner to php.
this is my google map.
http://ceylonembedded.com/map2.php
I want a user to be able to draw a boundary when he accesses my site froma mobile or from a browser to be able to generate an alert by the system when something crosses the boundry.
Can someone please tell me what the better way to do this?
I understand I need to know good Google map API.
other than that do I have to lean JavaScript?
Or do I learn Jason? or any other technique?
A series of guidance would be so much appreciated.
One possible way would be to make the whole website a canvas in html5, and every frame, import the image from a offscreen google map. Then, you could draw whatever you'd want on your canvas using javascript; however, I cannot guide you through the process, it's just a hypothetical solution.

UK postcodes with SimpleMaps

I'm using this simple maps plugin on a site that I'm currently building http://simplemap-plugin.com/demo/ It's based on google maps API. I only have Zip (in the UK postcode) input visible so this has to be used as a base for the search. The search functionality works fine if you use a full postcode for example W1U *PZ but if you simply type W1 you end up getting a result for a road in Algeria. Does anyone know if there is away in the gMaps API to only search postcodes and exclude any Roads, so that typing the start of a postcode (the area code) will give the desired result.
Perhaps the simplest way would be to simply limit the results to a specific country, in this case I'm presuming the UK.
https://developers.google.com/maps/documentation/geocoding/#RegionCodes
The problem you're going to have with such a query however is how to decide which result to return, simply querying 'W1' is going to return an series of arbitrary addresses whose postcodes contain 'W1' for example NW1. You may be best specifying a minimum length?

To show the route by clicking between two points on Google map in Blackberry

I am using JavaScript code to show the multiple pin points on Google Maps using Brownfield. I set the first clicked point as the center point, and when the user clicks on any other point (which is not the center point) I want to display a route mapped from the center point to that clicked point.
I would appreciate help of any sort, including ideas besides using JavaScript.
Google has a number of services available to people who program using their Maps. Go to https://developers.google.com/maps/documentation/javascript/reference and check out the directions services. I'm not very familiar with them, but I'm guessing it's similar to their other services. You make a directions request object supplied with point a and point b, and it will send a message to Google asking for the appropriate directions, which will be returned in some sort of result object that you can use to show the way. Update point b each time the user clicks and resend the google request, and it should update the path. Check out the API and it shouldn't be too hard to get it working. As for alternatives to javascript, Google Maps is written all in javascript, so there really is no other way. But I know from experience, most of their supplied code works really well, so I bet you can get it working!
Following link will show the route between two points:
J2ME/Android/BlackBerry - driving directions, route between two locations

Categories