Removed Django Geoposition and used Gmaps API to draw site map

Change-Id: I5f93cc84bb011034cf32fcf06ef5743667740e20
diff --git a/containers/xos/Dockerfile.base b/containers/xos/Dockerfile.base
index 5a98edb..6c73f6a 100644
--- a/containers/xos/Dockerfile.base
+++ b/containers/xos/Dockerfile.base
@@ -43,7 +43,6 @@
     django-encrypted-fields \
     django-extensions \
     django-filter \
-    django-geoposition \
     django-ipware \
     django-suit==0.3a3 \
     django-timezones \
diff --git a/xos/core/admin.py b/xos/core/admin.py
index f2a7156..ed52345 100644
--- a/xos/core/admin.py
+++ b/xos/core/admin.py
@@ -1092,7 +1092,7 @@
 class SiteAdmin(XOSBaseAdmin):
     #fieldList = ['backend_status_text', 'name', 'site_url', 'enabled', 'is_public', 'login_base', 'accountLink','location']
     fieldList = ['backend_status_text', 'name', 'site_url', 'enabled',
-                 'login_base', 'latitude', 'longitude', 'is_public', 'hosts_nodes', 'hosts_users']
+                 'login_base', 'is_public', 'hosts_nodes', 'hosts_users', 'latitude', 'longitude']
     fieldsets = [
         (None, {'fields': fieldList, 'classes': [
          'suit-tab suit-tab-general']}),
@@ -1114,6 +1114,10 @@
     admin_inlines = [ControllerSiteInline]
     search_fields = ['name']
 
+    suit_form_includes = (
+        ('../templates/admin/core/site/location_map.html', 'middle'),
+    )
+
     @property
     def suit_form_tabs(self):
         tabs = [('general', 'Site Details'),
diff --git a/xos/core/models/site.py b/xos/core/models/site.py
index a827672..e0d2fc5 100644
--- a/xos/core/models/site.py
+++ b/xos/core/models/site.py
@@ -3,7 +3,7 @@
 from django.db.models import Q
 from django.contrib.contenttypes.fields import GenericRelation
 from django.core.exceptions import PermissionDenied
-from geoposition.fields import GeopositionField
+# from geoposition.fields import GeopositionField
 from core.models import PlCoreBase,PlCoreBaseManager,PlCoreBaseDeletionManager
 from core.models import Tag
 from core.models.plcorebase import StrippedCharField
diff --git a/xos/templates/admin/core/site/location_map.html b/xos/templates/admin/core/site/location_map.html
new file mode 100644
index 0000000..d40734e
--- /dev/null
+++ b/xos/templates/admin/core/site/location_map.html
@@ -0,0 +1,63 @@
+<div class="panel fieldset-body">
+  <div class="form-group field-longitude ">
+    <label class="control-label col-xs-12 col-sm-2">
+      <label for="id_location">Location:</label>
+    </label>
+    <div class="form-column widget-NumberInput col-xs-12 col-sm-8 col-md-6 col-lg-4">
+      <div id="map" style="height: 300px"></div>
+    </div>
+  </div>
+</div>
+
+<script>
+  function initMap(){
+    
+    // registering inputs
+    var latField = $('input#id_latitude');
+    var lngField = $('input#id_longitude');
+
+    // reading coordinates
+    var latitude = latField.val();
+    var longitude = lngField.val();
+    var siteName = $('input#id_name').val();
+
+    console.log(latitude, longitude);
+    if(latitude === '' || longitude === ''){
+      // NOTE this feature is available only over HTTPS
+      // navigator.geolocation.getCurrentPosition(function(position) {
+      //   var myLatLng = {lat: parseFloat(position.coords.latitude), lng: parseFloat(position.coords.longitude)};
+      //   createMap(myLatLng, siteName);
+      // });
+      createMap({lat: 0, lng: 0}, siteName);
+    }
+    else{
+      var myLatLng = {lat: parseFloat(latitude), lng: parseFloat(longitude)};
+      createMap(myLatLng);
+    }
+
+    function createMap(myLatLng){
+      // set the map
+      var map = new google.maps.Map(document.getElementById('map'), {
+        center: myLatLng,
+        zoom: 8
+      });
+
+      // set the marker
+      var marker = new google.maps.Marker({
+        position: myLatLng,
+        map: map,
+        title: siteName,
+        draggable: true,
+        animation: google.maps.Animation.DROP,
+      });
+
+      // listen for dragend events and update the form
+      google.maps.event.addListener(marker, 'dragend', function() {
+        latField.val(marker.getPosition().lat());
+        lngField.val(marker.getPosition().lng());
+      });
+    }
+  }
+
+</script>
+<script src="https://maps.googleapis.com/maps/api/js?callback=initMap" defer></script>
\ No newline at end of file
diff --git a/xos/xos/settings.py b/xos/xos/settings.py
index f0dfe46..4a636c2 100644
--- a/xos/xos/settings.py
+++ b/xos/xos/settings.py
@@ -183,7 +183,7 @@
     'core',
     'services.mcord',
     'services.syndicate_storage',
-    'geoposition',
+    # 'geoposition',
     # 'rest_framework_swagger',
 )