Does CartoDB have a function to change center location based on user location? - cartodb

I have a map that is integrated in my application that has data points nationwide. I would like to have the map open up at the users current location. I only see documentation for setting the center on init.
Is this even possible or should I look to Google Maps instead?
EDIT:
I have the user location(city and state) in my native app's db. I would like to use that data and pass it to the map upon init.

Yep! Try this out...
navigator.geolocation.getCurrentPosition(loadPosition);
function loadPosition(position) {
lati = position.coords.latitude;
longi = position.coords.longitude;
map = L.map('map', {zoomControl: false}).setView([lati, longi], 15);
L.tileLayer('BASE_LAYER_URL', {maxZoom: 19,}).addTo(map);
Ah just saw your edit... try setting the desired latitude and longitude as variables and then use the map.setView function (below), perhaps triggered on some user event...
map.setView(new L.LatLng(latitudeVar, longitudeVar), 19);

Which geocoder are you using? I use leaflet.js and there is a share location pop-up that appears when I open my map and zooms to the users location. I am using an esri geocoder though.

Related

Is it possible to show map marker without input the Lat/Long with Leaflet

as the title stated, I'm trying to develop a GIS (geographic information system) webpage, whereby the user (admin) can input location and picture, and the marker will be shown/popup in the main page's map. I'm using Laravel framework and Leaflet for the map to implement the GIS. I manage to show the map without any marker yet. As the admin want to add the location to show the marker in the main page's map, normally what i've seen is that you need to include the Lat/Long for that specific location. It is true that including Lat/Long can make the marker more accurate to pin point the exact location, and I think it is necessary thing to include, as it is the main source of information to the system for pin point the location. But as a user, sometimes they not as diligent as we thought, the problem will occur if they left the lat/long to 0, because they are too lazy to search for the lat/long, thus making the initial goal which is to show marker in the main map fail.
Is there a way to make the Lat/Long automatically filled as the user type their location information? Or is there any other technologies for the GIS that I could implement/use?
Thank you.
If I'm not mistaken, then you are asking about this like
https://developers.google.com/maps/documentation/geocoding/overview

Get Co-ordinates based on the marker location over the google map

Aoa,
I am working on a web application where a shop vendor must put a latitude and longitude of his/her shop.
It is easy to get if he/she is using application from the shop. But if he/she is somewhere else i want to show a map option to the vendor where he/she could search his/her shop point it. And I could get co-ordinates from that marker position.
I have studied google map api found a lot of useful things but couldn't understand how to achieve this as I am unable to find anything regarding getting co-ordinates from the marker.
It will be great if anybody could guide me that where should I look or what should I study to solve my issue.
Thanks in advance..
You can use the Maps JavaScript API to put a marker every time a certain point in the map was clicked then get the coordinates of the point and display it so that your user can directly get the exact coordinate of the marker. Here is a simple code I made to demonstrate this.
In the code, I used a listener to the map to check for every click on the map and put a marker on it. It will then update the label display with the coordinate of the marker.
map.addListener('click', function(event) {
addMarker(event.latLng);
document.getElementById("text").innerHTML = event.latLng.lat() + ',' + event.latLng.lng();
});
Hope this helps!
Right-click on the red marker on Google Maps after searching the location, select "what's here?" and you will see the coordinates in a pop-up.

Alternatives to using a MovieClip or BitmapData for an image?

I've been trying for two days to find an alternative to loading an image into my current project. I am using Adobe Flash Professional CS6 as my IDE and Animation program. I would like to be able to display an image in my application. What I am trying to do is have the image display onto the screen, the user enters the PLU associated with the image, and if the PLU is right then they receive a point. I have everything else already to go, but I just can't find an efficient way to deal with loading the image.
Right now I'm using this to accomplish getting my image on the display:
var myDisp:Layer0 = new Layer0();
var bmp:Bitmap = new Bitmap(myDisp);
spDispBox.addChild(bmp);
The above code works just find, but the limitation I can't get around is that I'm going to have to import each image into the library and then consecutively code each part in. I wanted to stick to OOP and streamline this process, I just don't know where I should turn to in order to accomplish my project goal. I'm more than happy to give more information. Thanks in advance, everyone.
July, 26, 2014 - Update: I agree, now, that XML is the way to go. I'm just having a hard time getting the grasp of loading an external XML file. I'm following along, but still not quite getting the idea. I understand about creating a new XML data object, Loader, and URLRequest. It's just loading the picture. I've been able to get output by using trace in the function to see that the XML is loaded, but when I go to add the XML data object to the stage I'm getting a null object reference.
I'm going to try a few more things, I just wanted to update the situation. Thanks again everyone.
it seems like these images are in your FLA library. To simplify your code you can make a singleton class which you can name ImageFactory (factory design pattern) and call that when needing an image which will return a Sprite (lighter than a MovieClip)
spDispBox.addChild( ImageFactory.getImageA() ); // returns a Sprite with your image
and in your ImageFactory
public function getImageA():DisplayObject {
var image:Layer0 = new Layer0(); // image from the FLA library
var holder:Sprite = new Sprite();
holder.addChild( new Bitmap( image ) );
return holder;
}
also recommend using a more descriptive name than Layer0

Windows Phone 7.5 - How to calculate route on map image?

In my app for WP7.5, user can navigate into the university. He can see on the map his initial position acquired by scanning a Qr Code. Map image is Canvas background. Once he chooses the destination whose X and Y coordinates are known, how can I draw on the map the route from user's current location to the destination? I don't know if it is possible.
This is the working code that allows to show user's starting position on the map.
public void MarkLocation(ImageBrush imgmap, int posizioneX, int posizioneY)
{
Canvas.Background = imgmap;
Image imgmarker = new Image();
imgmarker.Source = new BitmapImage(new Uri("Images/marker.png", UriKind.Relative));
Canvas.SetLeft(imgmarker, posizioneX);
Canvas.SetTop(imgmarker, posizioneY);
Canvas.Children.Add(imgmarker);
}
I hope you can help me! Thanks in advance.
If you used the BingMapsDirectionsTask (in WP7) or the MapsDirectionsTask (in WP8) and the user will get a full navigation experience including showing the route and you'll not need to worry about dynamically generating images or overlaying items on a Map control.

Is it possible to change image of google.maps.GroundOverlay using javascript?

I am using Google Maps for a weather information display web.
I want to show the cloud condition for past seven days.
I am using overlays to display clouds on my web.
Now my question is can we change image of google.maps.GroundOverlay using javascript?
I believe it is not possible to change the image of a GroundOverlay. The image is set in the constructor and there is currently no setter documented to change it.
What you could try is to create two GroundOverlays with the same coordinates but pass the constructor map:null on one of them so it doesn't show on your map. Then, when you want to replace the image, call setMap(null) on the overlay that is showing--that will hide it--and then call setMap(map) (assuming you set your map to a variable named map) on the overlay that you want to show.
There's currently no way to change GroundOverlay's image via maps API. Instead, create new GroundOverlay with the same bounds for the new image. And remove the original GroundOverlay.
This has changed from 2011.
In Google Maps API V3, GroundOverlay class extends MVCObject which has getters and setters.
So you can indeed change image of ground overlay with overlay.set("url", newImage). Similarly, you can change overlays bounds with overlay.set("bounds",bounds).
After changing overlay properties, you have to reassign the map object to it with overlay.setMap(map).

Resources