It would be cool if a mobile visitor could see his position marker moving in real time similar to how it's done in Google map. Is something like this possible with ip_geoloc? If not please consider adding such a feature. ^^ I've done some goggling and found watchPosition option, http://leafletjs.com/reference.html#map-locate-options , in Leaflet should enable this feature. How should I go about enabling watchPosition in ip_geoloc?

Comments

tkittich’s picture

Issue summary: View changes
tkittich’s picture

I've found Leaflet.Locate https://github.com/domoritz/leaflet-locatecontrol that should work nicely. According to https://drupal.org/comment/7062258#comment-7062258 , extract Leaflet.Locate in a theme and override the template ip-geoloc-leaflet.tpl.php by adding the follow code seems to work great with leaflet maps. ^^

  $path = drupal_get_path('theme', 'THEMENAME');
  // Increase weight so we're included after 'leaflet.drupal.js'
  $options = array('type' => 'file', 'weight' => 10);
  drupal_add_css("$path/leaflet-locatecontrol/src/L.Control.Locate.css", $options);
  drupal_add_js("$path/leaflet-locatecontrol/src/L.Control.Locate.js", $options);
  drupal_add_js('
(function ($) {
	$(document).bind("leaflet.map", function(e, map, lMap) {
		// Leaflet.Locate
		var lc = L.control.locate({locateOptions: {enableHighAccuracy: true}}).addTo(lMap);
		lc.locate(); // request location update and set location
	});
})(jQuery);', array('type' => 'inline'));
RdeBoer’s picture

This looks great tkittich!
Must try when I find some time.
Rik

RdeBoer’s picture

kipper’s picture

Hi!

I tried it and it works well!!! But I have a problem to solve:
The button turns white, and the icon of the marker is missing.

Even in the demo (demo_mapbox) library "leaflet-locatecontrol" downloaded from here: https://github.com/domoritz/leaflet-locatecontrol icon is missing.

I investigated for hours but I can not solve this problem

Any help / suggestion?

P.S. I tried several options in sight and I discovered that the script (trick :)) of tkittich overwrites the template "ip-geoloc-leaflet.tpl.php" but fortunately the button "Add a full-screen toggle to the map" (activated in the view) it is shown.

The other options even if activated are overwritten and are not shown:
- Add an imperial (miles) scales
- Add a metric (km) scales
- Add an indicator showing the active zoom level
- Add a reset button
- Add cluster toggle button
- Enable mini-map inset

...but for my project goes well that is displayed:
- Add a full-screen toggle to the map
It is the only one that is NOT overwritten !!!

good trick tkittich !!!

Many Thanks

dwadson’s picture

The button is white, with no icon, because it requires the Font-Awesome css. Either need to load it in that overridden template, or use custom markers in the view.

But still doesn't address the other options being overwritten and not shown...

abdolmaleki’s picture

The other options even if activated are overwritten and are not shown:
- Add an imperial (miles) scales
- Add a metric (km) scales
- Add an indicator showing the active zoom level
- Add a reset button
- Add cluster toggle button
- Enable mini-map inset