Geolocation field

That is how current plugins are added.

Oh, I see what you mean. Thanks a lot for the clarification

Cheers

Hi @chabito79

Could you pls give some more insight on how you achieved this? How were you able to access the map’s HTML? Did you have to use a separate field other than the geolocation field itself?

Thanks

I dont have the project’s code anymore…but I remember I ended up integrating google maps instead of leaflet.

I used an HTML field and injected the map on it (following the standard way)… here’s a nice tutorial about it.

Regards

1 Like

Thanks a lot @chabito79

This was very helpful indeed

Cheers!

This is the code for showing popup on the marker. The below code can be included on refresh(frm) trigger.

var map = frm.get_field("geolocation_field").map;
var latlng = L.latLng({'lat':<value>, 'lng': <value>});
var marker = L.marker(latlng);
			
map.flyTo(latlng, map.getZoom());
marker.addTo(map);
marker.bindPopup(<content>).openPopup();
5 Likes

that great

I want to use restapi to send geojson to erpnext. but I have a trouble, could you check this?
Thank you.

Check the json

Nested “features” is array of objects

1 Like

Thank for your reply, I tried fixed follow your suggestion but it still not work, the map is default, dont’ have a point here

dd = {
“name1”: “Hcm096”,
“odo”: 200,
“geolocation”: json.dumps(
{“type”: “FeatureCollection”,
“features”: [{
“type”: “Feature”,
“geometry”: {
“type”: “Point”,
“coordinates”: [
106.6964048,
10.7511488]
}
}
]
}
)
}
data = json.dumps(dd)
r = requests.post(url, data, auth=(‘59aa898bdfdf713’, ‘1365c7955faa000’))
print(r)

Example command:

curl -Ssl -X POST https://erp.example.com/api/resource/ToDo \
    -H "Content-Type: application/json" \
    -H "Authorization: token $api_key:$api_secret" \
    -H "Accept: application/json" \
    -d '{
        "description": "ToDo Mumbai",
        "todo_location": "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{},\"geometry\":{\"type\":\"Point\",\"coordinates\":[72.867851,19.088689]}}]}"
    }'

todo_location is a custom Geolocation field added on ToDo

3 Likes

Hi all

Anyone got this error/warning on mobile app-android?

Geolocation error: application does not have sufficient geolocation permissions

If so, how did you resolve it?

Hi @glz

You’ll need to recompile the app yourself and include the Cordova Geolocation Plugin

Cheers

Mind explaining how to go about this please?

The ERPNext Android app is built with Cordova. You’ll need to research on how to build a Cordova app and follow the steps in the ERPNext Mobile Github repo at GitHub - frappe/mobile: Mobile App for Frappe built on Flutter

Cheers

This is in order. Was just wondering whether this means, I will end up with a different app from the mainstream?

Yes :pensive:

Ok. Thank you. Will do so.

Hello, I tried the first code on this post and the results are not 2 circles on the map as shown in the diagram. There’s nothing happening.

I want to make a system where I enter coordinates (longitude and latitude) then points are created and joined on the map. How can I go about it?

@Duncan_Nkhata @adam26d

Thanks a lot @mujeerhashmi