Destroy polygon nokia maps api - windows-phone-8

I made a script to create dynamic polygons, but to update its value will need to remove it to create another polygon.
The problem is that I'm not finding the solution to remove it. Anyone know how to do?
Thank you!
edited: I am using javascript..

You can update the MapLayer count with your dynamic pin updater, something like this that i have successfully tried
private void mapPinUpdater(List<String> lat, List<String> log, Boolean is_from_stored_location) {
int count_ofLayer = mapWithMyLocation.Layers.Count;
if (!is_from_stored_location && count_ofLayer >= 1)
mapWithMyLocation.Layers.RemoveAt(mapWithMyLocation.Layers.Count - 1);
MapLayer MyLayer = new MapLayer();
this would remove the previous layer and update the latest layer with your new pins.

Related

Google maps using android studio

I am developing an application which requires to mark the current location of an user onto google maps. I have already got the code for setting up a marker on the current location.
private void handleNewLocation(Location location) {
Log.d(TAG, location.toString());
//get the new latitude and longitude
double currentLatitude = location.getLatitude();
double currentLongitude = location.getLongitude();
//create object to store them
LatLng latLng = new LatLng(currentLatitude, currentLongitude);
//create marker with the new position
MarkerOptions options = new MarkerOptions()
.position(latLng)
.title("I am here!");
//add marker to the map
mMap.addMarker(options);
//move camera to current location
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
}
There are no errors shown on compilation. But when running on emulator , it displays "MapActivity has stopped working".
I am using Nexus 5 API 21x86 android virtual device to run the app.
Please help !!!!!!!
I think there is lots of problems, please refer to here, do it step by step, you will get the map.
Also, for the Marker part, please refer to here.

How can Programmatically adding multiple points to the map using esri in flex map

I wanna add Multiple Marker to esri map by using flex 4.6 on flash builder platform
`
private function addSomeMarkers(x:Number,y:Number):void
{
// This is just to show how to add markers
// using ActionScript code as opposed to MXML tags.
//(lat, lon, new SpatialReference(102697));
// outSR:SpatialReference = new SpatialReference(4326);
//GCS_WGS_1984
var myGraphicMarker:Graphic = new Graphic(new MapPoint(y,x, new SpatialReference(102100)),
new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_DIAMOND, 14, 0x009933));
myGraphicMarker.toolTip = "Marker added with ActionScript";
myGraphicsLayer.add(myGraphicMarker);
myGraphicMarker=null;
}`
These is my current function recives an (x,y) from dataBase but when i run program it just add only one the first recived x,y .
I checked my my code and im sure the function recives multiple point x,y....
Please help me and thank you>>>>>>>>>>>>>>>>>>>>>>>>>>>
I am working on same type of program and its working fine for me. May be you can try with some hard-coded values for Map points first. As I can see you are interchanging the positions of "y" and "X" in the map point.
var myGraphicMarker:Graphic = new Graphic(new MapPoint(y,x, new SpatialReference(102100)),
new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_DIAMOND, 14, 0x009933));

Android Google Map how to check if user is in marker circle region

I am using Google Maps, and want to be able to detect if a user is in the radius of a Marker (placed on map), using the users current location. I have the users current location coordinates (latitude and longitude) and the marker's coordinates, but do not know how to calculate whether the user is in the area. The picture below might best describe what I want to do.
I have an algorithm like this:
map.OnInfoWindowClickListener(new OnInfoWindowClickListener()){
public void isUserInArea(Marker marker){
float[] distance = new float[2];
//users current location
Location.distanceBetween(currentLocation.getLatitude(),currentLocatiocation.getLongitude(),
marker.getPosition().latitude, marker.getPosition().longitude, distance);
}
Which doesn't find if the current location is within marker region because I can't get hold of the markers circle. It's the closest i've got to it however. Would appreciate help.
To help, I add a circle to a map like this
// adding circle to map
circleOptions = new CircleOptions();
circleOptions.center(new LatLng(locationlist.get(i)
.getLatitude(), locationlist.get(i).getLongitude()));
circleOptions.radius(20);
circleOptions.strokeColor(Color.BLUE);
circleOptions.fillColor(Color.BLUE);
map.addCircle(circleOptions);
//check that all tasks are in circle radius
Marker locationMarker = map.addMarker(markerOp);
locationMarker.showInfoWindow();
I use this:
Location.distanceBetween(mMarker.getPosition().latitude,
mMarker.getPosition().longitude, mCircle.getCenter().latitude,
mCircle.getCenter().longitude, distance);
if (distance[0] > mCircle.getRadius()) {
//Do what you need
}else if (distance[0] < mCircle.getRadius()) {
//Do what you need
}
Why don't you use proximity alerts?
This is what you can do: instead of drawing a circle, place a Marker on the map like so:
map.addMarker(new MarkerOptions()
.title(name)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.gpsmap))
.position(coordinates)
.flat(true)
.rotation(90));
and then add a proximity alert to it calling the following method:
// Proximity alert
private void addProximityAlert(double lat, double lng, int id){
Intent intent = new Intent(PROX_ALERT_INTENT);
PendingIntent proximityIntent = PendingIntent.getBroadcast(this, id, intent, Intent.FLAG_ACTIVITY_NEW_TASK);
locationManager.addProximityAlert(lat, lng, POINT_RADIUS, EXPIRATION, proximityIntent);
}
where EXPIRATION = -1 (so the proximity alert doesn't expire) and POINT_RADIUS takes the values of the radius of your previous circle.
Then you need to add a proximity alert listener to the map:
IntentFilter filter = new IntentFilter(PROX_ALERT_INTENT);
registerReceiver(new ProximityIntentReceiver(), filter);
where PROX_ALERT_INTENT = "yourProjectPackageName.ProximityActivity";
Hope this helps
This tutorial can help your requirement.
User entry exit proximity alert
all the best.

Box2d dynamic circle body passing through my static polygon body?

I've created a "leaning wall" with box2d using the b2PolygonShape.SetAsArray function, and my player object (dynamic b2CircleShape) is able to push into it and eventually pass through it. However when I use SetAsBox it will no longer pass through it. Does anybody have an idea as to why this is happening?
The array I am using:
// array
var vertices:Array = [];
vertices[0] = new b2Vec2(0, 0);
vertices[1] = new b2Vec2(0, 506);
vertices[2] = new b2Vec2(50, 506);
vertices[3] = new b2Vec2(100, 0);
You need to reverse the order of these vertices so that the polygon is 'wound' counter-clockwise.

Calling map.fitBounds() Multiple Times in Google Maps API v3.0

I've just begun using the Google Maps API (v3.0) and have had a good deal of success so far. I am loading a set of objects with Latitude & Longitude values from a database, passing them into my script, and looping over them in the script in order to add them to the map.
I am using the "bounds.extend() / map.fitBounds()" method of setting the map's zoom & bounds (see code below), which works as expected the first time around; however, if I clear out the existing markers, fetch another set of objects, and do the same thing on the same map instance, it sets the bounds incorrectly, usually resulting in a minimum zoom (an astronaut's view).
My suspicion is that my map object has some memory of the previous set of bounds that I've given it and that I need to find a way to clear these bounds before assigning my new ones, but I really can't be too sure.
Any help is greatly appreciated!
var locationList = [];
for (var i = 0; i < mapPoints.length; i++) { // mapPoints is a collection of DTOs
var mapPoint = mapPoints[i];
var location = new google.maps.LatLng(mapPoint.Latitude, mapPoint.Longitude);
locationList.push(location);
var marker = new google.maps.Marker({
map: map,
icon: '/Content/images/map/' + mapPoint.Status.Icon,
shadow: '/Content/images/map/shadow.png',
position: location
});
markers.push(marker); // markers is an Array that is managed outside this loop
}
var bounds = new google.maps.LatLngBounds();
for (var j = 0; j < locationList.length; j++)
bounds.extend(locationList[j]);
map.fitBounds(bounds);
This isn't the answer, so to speak, but a (slightly hacky) workaround that I discovered on a thread in the Google Maps Javascript API v3 group:
//map.fitBounds(bounds);
setTimeout( function() { map.fitBounds( bounds ); }, 1 );
if the above answer doesn't work for you (it didn't for me), the problem might lie in bootstrap (assuming you're using it). bootstrap modals specifically generate all sorts of wonky behaviour when i embed a map object in it.. curiously correcting itself if/when i drop an 'alert' in there.. in any case, i solved all my problems by just building my own modal (ie, not using bootstraps modals).