I am developing an application which shows the current location of the user. I want to display a marker on the current location of the user.
I have used an image as marker to display current location. But i want to display an animated arrow showing the range just like in the google maps android app. Can anyone please tell me how to achieve this. Any sample code will be of great help...
try this tricky solution...
if u use javascript, try setInterval() to cahnge image if .gif doesn't work.
function runAnimation(callback){
setInterval(function(){
// set new marker here
// var newVal = callback(); <-- use callback to get new value
}
, 500); // interval in millisec
}
Related
I am using HERE map SDK in my Android app, I get geo location (lat/lon) every 5 seconds. When move the marker from location 1 to location 2, the marker jumps from location 1 to location 2. Does HERE map SDK have an api to move the marker smoothly from location 1 to location 2?
heres how i did it .
before i start tracking the user' location i get his last known location wiht this line of code :
if (isLocationEnabled()) {
LocationThread thread = new LocationThread(this, location ->{
clearPassageiroMapMarker();
passageiro.setLat(location.getLatitude());
passageiro.setLongitude(location.getLongitude());
addPassageiroMarker(new GeoCoordinates(location.getLatitude(),location.getLongitude()),R.drawable.ic_passageiro);
return null;
});
thread.requestLocation();
notice that i add its marker ONCE and only once .. heres the code for that :
public void addPassageiroMarker(GeoCoordinates geoCoordinates, int resourceId) {
MapImage mapImage = MapImageFactory.fromResource(this.getResources(), resourceId);
Anchor2D anchor = new Anchor2D(0.5f, 1.0f);
mapMarker = new MapMarker(geoCoordinates, mapImage, anchor);
mapView.getMapScene().addMapMarker(mapMarker);
mapMarkerPassageiroList.add(mapMarker);
}
notice that i have a mapmarker declared globably ,because im planning on using only one instance of marker throughout the entire instance of the activity...
heres the line of code that updates the marker whenever u get new set of coordinates :
mapMarker.setCoordinates(new GeoCoordinates(location.getLatitude(),location.getLongitude()));
took me a long while to find it out but im glad i did.
however i think if ur loooking for a fancy way of displaying the marker moving like uber has etc, u might have to create an animation of your own.
I am a newbie in android development and currently working on an app where i need to show a marker moving along a path(poly-line). I have googled a lot for the functionality and got various answers too but for now i have selected the answer from this
question which better suits the requirements. But the problem with the solution is the marker moving very fast. Please suggest me any correction or other solution that will slow down the speed of animation of moving marker or something like that.
Thanks
From this answer in related SO post, you need to update the marker more than every 1/10 fraction of the polyline (at least every few pixels). Call the update method more frequently and don't delete and re-add the marker.
Sample code:
var counter = 0;
interval = window.setInterval(function() {
counter++;
// just pretend you were doing a real calculation of
// new position along the complex path
var pos = new google.maps.LatLng(35, -110 + counter / 100);
marker.setPosition(pos);
if (counter >= 1000) {
window.clearInterval(interval);
}
}, 10);
Check these related SO threads which might help:
move marker on google maps api 2
Google map: moving marker and map together smoothly along with user?
Hope this helps!
I am developing an application in which I need to use maps offline. I'm using osmdroid and osmbonuspack
I have implemented code to display user's current location. And display boundary by importing KML content.
How can I set alarm to notify user, when user come closer(about 50m-100m) to that boundary?Click to see the image
You can buffer the area by (50m, 100m) and use LocationManager #addProximityAlert() to set a trigger.
Since the last two weeks i am developing a Navigation App.
I want to set an Pointer that is showing me the current Location.
How I can make this without using the Marker ? Or did I have to use the Marker ?
If you want to display the current location, you can use one of the following osmdroid Overlays:
MyLocationOverlay or MyLocationNewOverlay: handling GPS positionning
Or DirectedLocationOverlay: GPS position/direction/precision to handle yourself.
By the way, Marker(MapView) should be defined... Your OSMBonusPack lib is probably not installed properly.
Marker startMarker = new Marker(mapView);
startMarker.setPosition(gp);
startMarker.setAnchor(Marker.ANCHOR_CENTER, Marker.ANCHOR_BOTTOM);
mapView.getOverlays().add(startMarker);
mapView.invalidate();
startMarker.setIcon(getResources().getDrawable(R.drawable.iconcurrentlocation));
startMarker.setTitle("Start point");
with this one u can set immag on yout cuurentLocation and the Important thing is that you have to import this
import org.osmdroid.bonuspack.overlays.Marker;
I hope this helps somebody
I am working on a cross platform app both for android and iOS. I am using phonegap as bridge between HTML5 and android/iOS.
In my database there is multiple geo point(latitude& longitude). It is easy to show a point in the map by below
//Javascript//collecting data from database with JSON
var map = new GoogleMap();
map.initialize("map_home_location",data[0].home_lat,data[0].home_lng);
////HTML5
<div class="rhtForm" style="height:250px;" id="map_home_location"></div>
One geo location point is showing properly.
But i want to show
1) multiple geo location point in a map with short description of each point.
2) When click into a point long description will show.
here description means other information stored with specific geo location point.
Thanks in advance.
Marker newMark =
map.addMarker(new MarkerOptions()
.position(lat,lng)
.title("title")
.snippet("short desc"));
Then you have the marker you just added in an object to modify if you want. Otherwise you cab just use add marker. The title and snippet pop up on clicking the marker by default.