I'm building a map centric app and having a small issue .
I am displaying my map and getting current location . I can see the blue dot on the map and the directional arrow appears sometimes .
However i can't find any way to set the bearing . (or set the arrow to the direction the phone is pointing at)
Such as in google maps app , when you move the phone around - you can see the user position showing a directional fog towards where the phone is pointing .
I am using the compass plugin and getting the compass reading between 0-360 , however i'm not sure how to add that to my map + user location to make the arrow point in that direction.
Any ideas how to proceed ?
I'm developing named Xamarin.Forms.GoogleMaps which can set bearing like Google Maps API.
amay077/Xamarin.Forms.GoogleMaps: Map library for Xamarin.Forms using Google maps API
// No animation
await map.MoveCamera(CameraUpdateFactory.NewCameraPosition(
new CameraPosition(
new Position(35.7104, 139.8093), // center
17d, // zoom
45d, // bearing(rotation)
60d))); // tilt
// With animation
await map.AnimateCamera(CameraUpdateFactory.NewCameraPosition(
new CameraPosition(
new Position(35.7104, 139.8093), // center
17d, // zoom
45d, // bearing(rotation)
60d)), // tilt
TimeSpan.FromSeconds(1));
Related
I have a leaflet map set with a CRS of L.CRS.SIMPLE and several Markers.
The tiles are custom tiles pulled from my server (the usual /zoom/x/y.png) format.
I'm building a mobile app with Android using the same tiles and so using Google Map the coordinate system is different but I would like to reuse all my Markers coordinate.
Is there a way to convert the marker's simple coordinate to a coordinate that can be used on the google map coordinate system ?
More info:
The map is a fictional game map that I have tiled myself from a hung PNG file.
I had set my Leaflet MAP CRS like this:
crs: L.Util.extend({}, L.CRS, {
code: "simple",
projection: L.Projection.LonLat,
transformation: new L.Transformation(1, 0, -1, 0)
}),
The WebApp let users add their own Markers on it, I had saved all the Marker lat/lng using what the leaflet map was giving.
I'm now trying to build a native Android app using the exact same tiles which works fine however I do not know how to put all the Marker on it since Google Map use the normal earth lat/lng coords.
Is it even possible to covert from L.CRS.SIMPLE to whatever Google Map uses ?
im trying to center the windows phone map between two points, adjusting center and zoom to make that points visible at the same time.
Im Android and IOS there are functions to do it, as example this is how to do it in Android:
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(myPos.getPosition());
builder.include(defaultPos.getPosition());
mapa.animateCamera(CameraUpdateFactory.newLatLngBounds(builder.build(), 50));
How can i do the same in WinRT?
Thanks in advance.
If you are targeting Windows Phone 8.1 instead of WinRT (Windows 8/8.1) then you can do the following:
var geoboundingBox = new Windows.Devices.Geolocation.GeoboundingBox(
new BasicGeoposition() { Latitude = 40, Longitude = -90 },
new BasicGeoposition() { Latitude = 45, Longitude = -100 });
map.TrySetViewAsync(new Geopoint(geoboundingBox.Center));
For the Bing Maps WinRT control you can do this in two different ways. The first is to create a LocationRect from the two points. This will create a bounding box for your locations. You can either set the map view to this LocationRect using the SetView method on the map which will center and zoom to these locations, or you can use the Center property of this LocationRect to set the view of the map such that it is centered on these two locations, without zooming into the map. Something like this should work:
var bounds = new LocationRect(new Location(40,-90), new Location(45,-100));
map.SetView(bounds.Center);
Another method requires a bit more calculation but a good option to know if you come across other map controls that don't have an easy solution like the first one I mentioned. This method consists of calculating the center coordinate between the two locations. I have a blog post on how to do this from a vey old version of Bing Maps here: http://rbrundritt.wordpress.com/2008/10/14/calculating-the-midpoint-of-a-line-segment/ The logic can be easily migrated to other programming languages.
It sounds like you are new to developing with Bing Maps in WinRT. I recommend checking out my free ebook on how to create location intelligent Windows Store apps. It goes into a lot of detail on how to create great apps using the Bing Maps control. You can download a copy of it here: http://rbrundritt.wordpress.com/my-book/
I tried integrating google maps tile layer into leaflet using leaflet-google plugin. Everything loads fine, but when i try to zoom in/out, first my custom feature layer zooms and then the google map tile layer zooms. Why don't they zoom together?
var map = new L.Map('map', {center: new L.LatLng(18.93718 , 72.79366), zoom: 10});
var googleLayer = new L.Google('ROADMAP');
map.addLayer(googleLayer);
and I am adding my feature layer by:
L.geoJson(inputgeoJson, {
style: style,
onEachFeature: onEachFeature
}).addTo(map);
Thanks!
The Google layer in Leaflet is a hack (a possibly illegal one), and involves using the Google Maps API within Leaflet. Since Leaflet and the Google Maps API have different zoom transition animations, you see this effect. You could use Google tiles directly in Leaflet, but that's definitely be illegal, not just maybe.
I have multiple addresses on the same street with the same house number, but with different apartment numbers. Google Maps Geocoding Service (v2) doesn't go down to apartment level accuracy for many addresses and just returned me the exact same geocode coordinates for them.
So the problem is that when I go to display them, only one pushpin shows up no matter how much you zoom in. And my question is; what is a good way to render multiple pushpins at the exact same house address? I've seen how craigslist.org creates a spiral out of the pushpins on their new map feature, but was wondering what my other options are as that seems like a workaround at best.
Ideas?
I solved this using Google's dynamic chart icons which allow you to put a number in the pin identifying that there are multiple markers on this exact some point. Basically, you call their "chart" url with some query params and they give you back your numbered icon which you can then place/set in the existing marker you have on that spot.
var markerImage = createMarkerImage(numDuplicates + 1);
existingMarker.setIcon(markerImage);
function createMarkerImage(text)
{
var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=" + text + "|FF8985|000000",
new google.maps.Size(21, 34),
new google.maps.Point(0,0),
new google.maps.Point(10, 34));
return pinImage;
}
NOTE: This solution uses a deprecated google API with no end date posted.
"Important: The Image Charts portion of Google Chart Tools has been
officially deprecated as of April 20, 2012. It will continue to work
as per our deprecation policy."
UPDATE:
I have moved away from the above solution since it's deprecated (and has performance impact for many markers) in leiu of the same end effect of a numbered marker, but using a path of coordinates defining polygon in the shape of a marker along with a .png for the marker shadow. Only reason I used my own custom marker is because I needed to create individual markers, each with a unique color (and possibly an embedded number), which the vanilla markers don't support.
I want to create an overlay on top of Google Maps that displays different streets in different colors.
In the Google Maps API it is possible to create markers and polygons that cover certain areas.
Is there a way to somehow mark different streets?
It sounds to me like you are interested in showing some application specific coloring for your Google maps display (rather than traffic maps).
If so , then you should check out custom overlays. You can create your own transparent background overlay tiles (with your colored streets), match them up with the Google maps tiles and then overlay them on the map. You can find a description of this stuff in the Maps API reference - Overlays.
I have actually been interested in trying this out, and this question might be a good excuse. I'll let you know how I go.
Edit: Ok, I tried this and it was pretty straightforward. You just need to grab the tiles images when the google maps page load (for the area you would like to overlay). Make sure you keep track of the origional urls, because these have the x,y coordinates that you will need to write your tile overlay method.
Edit the tiles with your colored roads then upload them to your web server. Add the following code to use your overlay on the regular map:
var myCopyright = new GCopyrightCollection("© ");
myCopyright.addCopyright(new GCopyright('Demo',
new GLatLngBounds(new GLatLng(-90,-180), new GLatLng(90,180)),
0,'©2007 Google'));
// Create the tile layer overlay and
// implement the three abstract methods
var tilelayer = new GTileLayer(myCopyright);
// properties of the tile I based my tile on
// v=w2.97&hl=en&x=38598&s=&y=49259&z=17&s=Galil.png
tilelayer.getTileUrl = function(point, zoom) {
if (zoom == 17 && point.x == 38598 && point.y == 49259)
return "../pics/times_square.png";
};
tilelayer.isPng = function() { return true;};
tilelayer.getOpacity = function() { return 1.0; }
var myTileLayer = new GTileLayerOverlay(tilelayer);
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(40.75740, -73.98590), 17);
map.addOverlay(myTileLayer)
This code overlays my Thing eats NY tile:
at x = 38598 and y = 49259 at zoom level 17.
It is possible to create markers and polygons in the Google Maps API. You need to create GPolygon and/or GPolyline objects
Have a look to these tutorials
And if you want to obtain the coordinate (latitude, longitude) of certain streets, you may have a look to the source code of this page
I am not sure to fully understand your question: do you want to mark some given streets ?
in that case, a quick-and-dirty way could be to get the coordinates of all the addresses of the street and build a GPolygon according to them...
Have you concidered using OpenStreeMaps?
Try digging into the code used to show the traffic overlay on the normal Google Maps site.
Edit: I just looked at the code, and it appears that even Google decided it was easier to implement this by just generating the traffic lines on the server and pulling them down as transparent PNG overlays.
I just found this link, and I think this could interest you. It is a JavaScript package that provides functionality for displaying multiple routes on Google Maps.
Is it what you were looking for ??