Google map in edit table page

This public forum is for user-to-user discussions of ASP.NET Maker. Note that this is not support forum.
Post Reply
aileen03
User
Posts: 5

Google map in edit table page

Post by aileen03 »

I have a project where for each record (point) I have coordinates (latitude and longitude).
In ASP.NET maker via the custom view tag, I am able to add Google Maps to show the all the points in the list page and the individual point on the view page of a particular record.
I would like to have the map to be displayed in the edit page of a particular record to show the latitude and longitude of the point in a field (example : Map).
Ideally, the Map field displaying the map would be dynamic and change when the latitude and longitude has been edited.
I was wondering if this is possible?

Cheers


Webmaster
User
Posts: 9427

Post by Webmaster »

You can do this by adding codes in the edit page start up script:

  1. You need to show the map in the edit page first
  2. To show a single map, make sure that you add a <div> with class = "ewGrid" to the edit page (Use jQuery.prependTo)
  3. Update the ewGoogleMaps array with the required properties. For example:

ewGoogleMaps[0] = { ... } ' Refer to list/view page for the required object properties

  1. To change the marker when a field is changed, you need to clear the original marker and add the new marker. Use jQuery .change method to detect changes in the field
  2. Update the googlemap customview tags to save the marker positions to an array

var ewGoogleMap;
var ewGoogleMapBounds;
var ewGoogleMapMarkers = []; //***
//...
function ew_ShowGoogleMap(map) {
//...
var marker = new google.maps.Marker({ // Marker
position: latlng,
map: gmap,
icon: icon null,
title: title
""
});
ewGoogleMapMarkers.push(marker); //***

  • You can then use the googlemaps setMap method to clear the marker:

    for (var i = 0; i < ewGoogleMapMarkers.length; i++) {
    ewGoogleMapMarkers[i].setMap(null);
    }

  • To update the new marker, update the map properties and call ew_ShowGoogleMap to show the map again

ewGoogleMaps[0].latlng = new google.maps.LatLng(..., ...);
ew_ShowGoogleMap(ewGoogleMaps[0]);


aileen03
User
Posts: 5

Post by aileen03 »

Thanks!


Post Reply