Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 17 additions & 1 deletion src/GoogleMaps.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ WARNING: Address lookups are Google APIs calls which are limited in the free tri
<attributeType name="Decimal"/>
</attributeTypes>
</property>
<property key="locationsEntity" type="entity" required="false">
<property key="locationsEntity" type="entity" required="false" allowNonPersistableEntities="true">
<caption>Locations entity</caption>
<category>Database / Microflow</category>
<description/>
Expand Down Expand Up @@ -234,6 +234,22 @@ WARNING: Address lookups are Google APIs calls which are limited in the free tri
</property>
</properties>
</property>
<property key="markerLabelAttributeContext" type="attribute" required="false">
<caption>Marker label (Context)</caption>
<category>Markers</category>
<description>For 'Datasource' 'Context'; Add a single character label inside the default marker to identify markers.</description>
<attributeTypes>
<attributeType name="String"/>
</attributeTypes>
</property>
<property key="markerLabelAttribute" type="attribute" required="false" entityProperty="locationsEntity">
<caption>Marker label (Database / Microflow)</caption>
<category>Markers</category>
<description>For 'Datasource' 'Database' or 'Microflow'; Add a single character label inside the default marker to identify markers.</description>
<attributeTypes>
<attributeType name="String"/>
</attributeTypes>
</property>
<!-- Maps styles -->
<property key="mapStyles" type="string" multiline="true" required="false">
<caption>Map styles</caption>
Expand Down
8 changes: 8 additions & 0 deletions src/GoogleMapsContext.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@
</property>
</properties>
</property>
<property key="markerLabelAttribute" type="attribute" required="false">
<caption>Marker label</caption>
<category>Markers</category>
<description>When using default markers, Google allows you to add a label to each marker. This can be used e.g. to number markers and make them easily recognizable.</description>
<attributeTypes>
<attributeType name="String"/>
</attributeTypes>
</property>
<!-- Maps styles -->
<property key="mapStyles" type="string" multiline="true" required="false">
<caption>Styles</caption>
Expand Down
11 changes: 9 additions & 2 deletions src/components/GoogleMapContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ interface GoogleMapContainerProps extends WrapperProps {
latitudeAttribute: string;
longitudeAttribute: string;
markerImageAttribute: string;
markerLabelAttribute: string;
addressAttributeContext: string;
latitudeAttributeContext: string;
longitudeAttributeContext: string;
markerImageAttributeContext: string;
markerLabelAttributeContext: string;
staticLocations: StaticLocation[];
markerImages: Array<{ enumKey: string, enumImage: string}>;
width: number;
Expand Down Expand Up @@ -124,10 +126,12 @@ class GoogleMapContainer extends Component<GoogleMapContainerProps, { alertMessa
this.props.latitudeAttribute,
this.props.longitudeAttribute,
this.props.markerImageAttribute,
this.props.markerLabelAttribute,
this.props.addressAttributeContext,
this.props.latitudeAttributeContext,
this.props.longitudeAttributeContext,
this.props.markerImageAttributeContext
this.props.markerImageAttributeContext,
this.props.markerLabelAttributeContext
].forEach(attr => this.subscriptionHandles.push(window.mx.data.subscribe({
attr,
callback: () => this.fetchData(contextObject), guid: contextObject.getGuid()
Expand Down Expand Up @@ -198,17 +202,20 @@ class GoogleMapContainer extends Component<GoogleMapContainerProps, { alertMessa
const longitudeAttribute = isContext ? this.props.longitudeAttributeContext : this.props.longitudeAttribute;
const addressAttribute = isContext ? this.props.addressAttributeContext : this.props.addressAttribute;
const markerImageAttribute = isContext ? this.props.markerImageAttributeContext : this.props.markerImageAttribute;
const markerLabelAttribute = isContext ? this.props.markerLabelAttributeContext : this.props.markerLabelAttribute;

const lat = mxObject.get(latitudeAttribute);
const lon = mxObject.get(longitudeAttribute);
const address = mxObject.get(addressAttribute) as string;
const url = this.getMxObjectMarkerUrl(mxObject.get(markerImageAttribute) as string);
const label = mxObject.get(markerLabelAttribute) as string;

return {
address,
latitude: lat ? Number(lat) : undefined,
longitude: lon ? Number(lon) : undefined,
url
url,
label
};
});

Expand Down
5 changes: 3 additions & 2 deletions src/components/Map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,14 @@ export class Map extends Component<MapProps, MapState> {

if (this.state.isLoaded && this.state.locations && this.state.locations.length) {
this.state.locations.map((locationObject, index) => {
const { latitude, longitude, url } = locationObject;
const { latitude, longitude, url, label } = locationObject;
if (this.validLocation(locationObject)) {
markerElements.push(createElement(Marker, {
key: index,
lat: latitude as number,
lng: longitude as number,
url
url,
label
}));
}
});
Expand Down
4 changes: 4 additions & 0 deletions src/components/Marker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export interface MarkerProps {
lat: number;
lng: number;
url?: string;
label?: string;
}

export const Marker: StatelessComponent<MarkerProps> = (props) => {
Expand All @@ -14,6 +15,9 @@ export const Marker: StatelessComponent<MarkerProps> = (props) => {
className: "widget-google-maps-marker-url",
style
});
} else if (props.label) {
return createElement("div", { className: "widget-google-maps-marker" },
createElement("div", { className: "widget-google-maps-marker-label" }, props.label.substring(0, 1)));
}

return createElement("div", { className: "widget-google-maps-marker" });
Expand Down
56 changes: 36 additions & 20 deletions src/ui/GoogleMaps.css
Original file line number Diff line number Diff line change
@@ -1,30 +1,46 @@
.widget-google-maps-wrapper {
position: relative;
position: relative;
}

.widget-google-maps-wrapper > div {
position: absolute;
top: 0; bottom: 0; left: 0; right: 0;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}

.widget-google-maps-marker{
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAccSURBVGiBtZldbBxXFcd/586svbNOnMaJ411HxalakNumqFKbUn8kDRISUj5QVRJEH1CpeAAJEAIJUV4qEwRqhEIbSAsvUVrxAKpLiuy6LbSlTvzVkjpUDURFcpuGSLbzIZtYtnezOzOHB9vpej3rmf3wX9qHPfeec/7/uXfOnDsjVAkKMvnw7hZcdxfwE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vg9sWTRdsWvk3saTA9FLdAlYkxUBaDw5MKG+PrX0X0WfWisRsIZCAGrVPa5wFhitdd3ja5lrzTG5v3Pf5J7OfWud5/+7d3U0ibpTcQAAAABJRU5ErkJggg==);
cursor: pointer;
width: 50px;
height: 50px;
padding: 0;
left: -25px;
top: -50px;
position: absolute;
.widget-google-maps-marker {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAccSURBVGiBtZldbBxXFcd/586svbNOnMaJ411HxalakNumqFKbUn8kDRISUj5QVRJEH1CpeAAJEAIJUV4qEwRqhEIbSAsvUVrxAKpLiuy6LbSlTvzVkjpUDURFcpuGSLbzIZtYtnezOzOHB9vpej3rmf3wX9qHPfeec/7/uXfOnDsjVAkKMvnw7hZcdxfwEMg9oNuA+sUpMyCfgJ4DTuHap5Ov918U0Grkl0oDvHjwoLVrbuJ+3+iPgd2CbIroeg3oB/nVgJMc/Vp3t1cJj4qETO9pb8kYOSzIVxXsMsO4KnTH4YmG3sH/lsulLCEKcnlf5z6FY8Bnyk2+PKheFCPfa+od7Ctnu5UsRLswE++1f0swRwGnVP8QpEX1+007hk5IF34pjqaUyQoyfqbjccH8luqLAHBU5NnJf3Q+VqpjSSsyvrdjp4i8wqeVKBBZz2Mu55JxXTx/YZdYRojbNnUxmxrLWp2UyHVP2Lu1Z2AoKrfIQi59ua3BilkjAp8rNifjulybzzCfyxXd5CKQsGNsTsSJ26vVB/0wq9Le0jc4HYVf5K0Vi1k/XE3EVDrDpZlZ5lYRAaAKc7kcl2ZmmUpnVpkprTXCD6Lyi7QiEw8/uE1d+4zA5hXEgGvz6RBSxdHgxNmccIKJiF6pRXZEKcuRar+41qMEiAC4fuMG0ytFqMK4QB/Kh/7CBWsVYY9AM3kXcDqdocYybKitXRl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s4qbXo+BLCMwSpBBOCjcuiWiC8dllCSEICtm+0XgdOl+kWFqp66MWe9VKpfWa9ML39lZ4fv65vkHVerhLRR70tNfSPDpTqWvCIATT0DQ6pa8lWLgO5yRECZQgBcX7uidKUl4LJRflauc9lCbn1t+GPj67Fy/QuhcKypb/BCuf5lCxFQz2SOoESu9cWhYynHO0IFX6/KFgLQ3Ds6r4YniXCCWwWe78uT0j2SroRLRUIA5tz1fxbl7+X6C/rWvK4/WSmPir8hAkzs2/kA+AMgNeGz86FZNXQ09wy9VymHilcEIPnKwBlV/lCqnyAvpHqGRqvBoSpCBNQY6xciTER2UibUdn9Zrc/TVRECkOw9fUF9jkZ2EHkm9Zd3PqlW/qoJAbAS9rOg/wqdKJyzHOu5auauqpAt3f2zqBwC3FWmuagc2tLdP1vN3FUVApBMpE6q8maxcUXfGHCSL1c7b1XKbyEm9rfvQM3bQF3B0Jz6urv51crLbSGqviIAyfuGR4HnV47IidQDQ2fXIuearAjA1Ud2ptysvg9sWTRdsWvk3saTA9FLdAlYkxUBaDw5MKG+PrX0X0WfWisRsIZCAGrVPa5wFhitdd3ja5lrzTG5v3Pf5J7OfWud5/+7d3U0ibpTcQAAAABJRU5ErkJggg==);
cursor: pointer;
width: 50px;
height: 50px;
padding: 0;
left: -25px;
top: -50px;
position: absolute;
}

.widget-google-maps-marker-url {
background-repeat: no-repeat;
cursor: pointer;
width: 50px;
height: 50px;
padding: 0;
left: -25px;
top: -50px;
position: absolute;
background-repeat: no-repeat;
cursor: pointer;
width: 50px;
height: 50px;
padding: 0;
left: -25px;
top: -50px;
position: absolute;
}

.widget-google-maps-marker-label {
background: #c0392b;
border-radius: 10px;
width: 18px;
text-align: center;
font-size: 16px;
left: 16px;
top: 7px;
position: absolute;
font-weight: bold;
color: #fff;
}
1 change: 1 addition & 0 deletions src/utils/ContainerUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface Location {
latitude?: number;
longitude?: number;
url?: string;
label?: string;
}

export interface StaticLocation {
Expand Down